home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gcc_260.zip / gcc_260 / varasm.c < prev    next >
C/C++ Source or Header  |  1994-07-11  |  107KB  |  3,884 lines

  1. /* Output variables, constants and external declarations, for GNU compiler.
  2.    Copyright (C) 1987, 88, 89, 92, 93, 1994 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. /* This file handles generation of all the assembler code
  22.    *except* the instructions of a function.
  23.    This includes declarations of variables and their initial values.
  24.  
  25.    We also output the assembler code for constants stored in memory
  26.    and are responsible for combining constants with the same value.  */
  27.  
  28. #include <stdio.h>
  29. #include <setjmp.h>
  30. /* #include <stab.h> */
  31. #include "config.h"
  32. #include "rtl.h"
  33. #include "tree.h"
  34. #include "flags.h"
  35. #include "function.h"
  36. #include "expr.h"
  37. #include "hard-reg-set.h"
  38. #include "regs.h"
  39. #include "defaults.h"
  40. #include "real.h"
  41. #include "bytecode.h"
  42.  
  43. #include "obstack.h"
  44.  
  45. #ifdef XCOFF_DEBUGGING_INFO
  46. #include "xcoffout.h"
  47. #endif
  48.  
  49. #include <ctype.h>
  50.  
  51. #ifndef ASM_STABS_OP
  52. #define ASM_STABS_OP ".stabs"
  53. #endif
  54.  
  55. /* This macro gets just the user-specified name
  56.    out of the string in a SYMBOL_REF.  On most machines,
  57.    we discard the * if any and that's all.  */
  58. #ifndef STRIP_NAME_ENCODING
  59. #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
  60.   (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'))
  61. #endif
  62.  
  63. /* File in which assembler code is being written.  */
  64.  
  65. extern FILE *asm_out_file;
  66.  
  67. /* The (assembler) name of the first globally-visible object output.  */
  68. char *first_global_object_name;
  69.  
  70. extern struct obstack *current_obstack;
  71. extern struct obstack *saveable_obstack;
  72. extern struct obstack *rtl_obstack;
  73. extern struct obstack permanent_obstack;
  74. #define obstack_chunk_alloc xmalloc
  75.  
  76. /* Number for making the label on the next
  77.    constant that is stored in memory.  */
  78.  
  79. int const_labelno;
  80.  
  81. /* Number for making the label on the next
  82.    static variable internal to a function.  */
  83.  
  84. int var_labelno;
  85.  
  86. /* Carry information from ASM_DECLARE_OBJECT_NAME
  87.    to ASM_FINISH_DECLARE_OBJECT.  */
  88.  
  89. int size_directive_output;
  90.  
  91. /* The last decl for which assemble_variable was called,
  92.    if it did ASM_DECLARE_OBJECT_NAME.
  93.    If the last call to assemble_variable didn't do that,
  94.    this holds 0.  */
  95.  
  96. tree last_assemble_variable_decl;
  97.  
  98. /* Nonzero if at least one function definition has been seen.  */
  99. static int function_defined;
  100.  
  101. extern FILE *asm_out_file;
  102.  
  103. static char *compare_constant_1 ();
  104. static void record_constant_1 ();
  105. static void output_constant_def_contents ();
  106. static int contains_pointers_p ();
  107. static void bc_output_ascii ();
  108.  
  109. void output_constant_pool ();
  110. void assemble_name ();
  111. int output_addressed_constants ();
  112. void output_constant ();
  113. void output_constructor ();
  114. void output_byte_asm ();
  115. void text_section ();
  116. void readonly_data_section ();
  117. void data_section ();
  118. void named_section ();
  119. static void bc_assemble_integer ();
  120.  
  121. #ifdef EXTRA_SECTIONS
  122. static enum in_section {no_section, in_text, in_data, in_named, EXTRA_SECTIONS} in_section
  123.   = no_section;
  124. #else
  125. static enum in_section {no_section, in_text, in_data, in_named} in_section
  126.   = no_section;
  127. #endif
  128.  
  129. /* Return a non-zero value if DECL has a section attribute.  */
  130. #define IN_NAMED_SECTION(DECL) \
  131.   ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
  132.    && DECL_SECTION_NAME (DECL) != NULL_TREE)
  133.  
  134. /* Text of section name when in_section == in_named.  */
  135. static char *in_named_name;
  136.  
  137. /* Define functions like text_section for any extra sections.  */
  138. #ifdef EXTRA_SECTION_FUNCTIONS
  139. EXTRA_SECTION_FUNCTIONS
  140. #endif
  141.  
  142. /* Tell assembler to switch to text section.  */
  143.  
  144. void
  145. text_section ()
  146. {
  147.   if (in_section != in_text)
  148.     {
  149.       if (output_bytecode)
  150.     bc_text ();
  151.       else
  152.     fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
  153.  
  154.       in_section = in_text;
  155.     }
  156. }
  157.  
  158. /* Tell assembler to switch to data section.  */
  159.  
  160. void
  161. data_section ()
  162. {
  163.   if (in_section != in_data)
  164.     {
  165.       if (output_bytecode)
  166.     bc_data ();
  167.       else
  168.     {
  169.       if (flag_shared_data)
  170.         {
  171. #ifdef SHARED_SECTION_ASM_OP
  172.           fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
  173. #else
  174.           fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
  175. #endif
  176.         }
  177.       else
  178.         fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
  179.     }
  180.  
  181.       in_section = in_data;
  182.     }
  183. }
  184.  
  185. /* Tell assembler to switch to read-only data section.  This is normally
  186.    the text section.  */
  187.  
  188. void
  189. readonly_data_section ()
  190. {
  191. #ifdef READONLY_DATA_SECTION
  192.   READONLY_DATA_SECTION ();  /* Note this can call data_section.  */
  193. #else
  194.   text_section ();
  195. #endif
  196. }
  197.  
  198. /* Determine if we're in the text section. */
  199.  
  200. int
  201. in_text_section ()
  202. {
  203.   return in_section == in_text;
  204. }
  205.  
  206. /* Tell assembler to change to named section.  */
  207.  
  208. void
  209. named_section (name)
  210.      char *name;
  211. {
  212.   if (in_section != in_named || strcmp (name, in_named_name))
  213.     {
  214.       in_named_name = name;
  215.       in_section = in_named;
  216.     
  217. #ifdef ASM_OUTPUT_SECTION_NAME
  218.       ASM_OUTPUT_SECTION_NAME (asm_out_file, name);
  219. #else
  220.       /* Section attributes are not supported if this macro isn't provided -
  221.      some host formats don't support them at all.  The front-end should
  222.      already have flagged this as an error.  */
  223.       abort ();
  224. #endif
  225.     }
  226. }
  227.  
  228. /* Create the rtl to represent a function, for a function definition.
  229.    DECL is a FUNCTION_DECL node which describes which function.
  230.    The rtl is stored into DECL.  */
  231.  
  232. void
  233. make_function_rtl (decl)
  234.      tree decl;
  235. {
  236.   char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
  237.  
  238.   if (output_bytecode)
  239.     {
  240.       if (DECL_RTL (decl) == 0)
  241.     DECL_RTL (decl) = bc_gen_rtx (name, 0, (struct bc_label *) 0);
  242.       
  243.       /* Record that at least one function has been defined.  */
  244.       function_defined = 1;
  245.       return;
  246.     }
  247.  
  248.   /* Rename a nested function to avoid conflicts.  */
  249.   if (decl_function_context (decl) != 0
  250.       && DECL_INITIAL (decl) != 0
  251.       && DECL_RTL (decl) == 0)
  252.     {
  253.       char *label;
  254.  
  255.       name = IDENTIFIER_POINTER (DECL_NAME (decl));
  256.       ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
  257.       name = obstack_copy0 (saveable_obstack, label, strlen (label));
  258.       var_labelno++;
  259.     }
  260.  
  261.   if (DECL_RTL (decl) == 0)
  262.     {
  263.       DECL_RTL (decl)
  264.     = gen_rtx (MEM, DECL_MODE (decl),
  265.            gen_rtx (SYMBOL_REF, Pmode, name));
  266.  
  267.       /* Optionally set flags or add text to the name to record information
  268.      such as that it is a function name.  If the name is changed, the macro
  269.      ASM_OUTPUT_LABELREF will have to know how to strip this information.  */
  270. #ifdef ENCODE_SECTION_INFO
  271.       ENCODE_SECTION_INFO (decl);
  272. #endif
  273.     }
  274.  
  275.   /* Record at least one function has been defined.  */
  276.   function_defined = 1;
  277. }
  278.  
  279. /* Create the DECL_RTL for a declaration for a static or external
  280.    variable or static or external function.
  281.    ASMSPEC, if not 0, is the string which the user specified
  282.    as the assembler symbol name.
  283.    TOP_LEVEL is nonzero if this is a file-scope variable.
  284.    This is never called for PARM_DECLs.  */
  285. void
  286. bc_make_decl_rtl (decl, asmspec, top_level)
  287.      tree decl;
  288.      char *asmspec;
  289.      int top_level;
  290. {
  291.   register char *name = TREE_STRING_POINTER (DECL_ASSEMBLER_NAME (decl));
  292.  
  293.   if (DECL_RTL (decl) == 0)
  294.     {
  295.       /* Print an error message for register variables.  */
  296.       if (DECL_REGISTER (decl) && TREE_CODE (decl) == FUNCTION_DECL)
  297.     error ("function declared `register'");
  298.       else if (DECL_REGISTER (decl))
  299.     error ("global register variables not supported in the interpreter");
  300.  
  301.       /* Handle ordinary static variables and functions.  */
  302.       if (DECL_RTL (decl) == 0)
  303.     {
  304.       /* Can't use just the variable's own name for a variable
  305.          whose scope is less than the whole file.
  306.          Concatenate a distinguishing number.  */
  307.       if (!top_level && !DECL_EXTERNAL (decl) && asmspec == 0)
  308.         {
  309.           char *label;
  310.  
  311.           ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
  312.           name = obstack_copy0 (saveable_obstack, label, strlen (label));
  313.           var_labelno++;
  314.         }
  315.  
  316.       DECL_RTL (decl) = bc_gen_rtx (name, 0, (struct bc_label *) 0);
  317.     }
  318.     }
  319. }
  320.  
  321. /* Given NAME, a putative register name, discard any customary prefixes.  */
  322.  
  323. static char *
  324. strip_reg_name (name)
  325.      char *name;
  326. {
  327. #ifdef REGISTER_PREFIX
  328.   if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX)))
  329.     name += strlen (REGISTER_PREFIX);
  330. #endif
  331.   if (name[0] == '%' || name[0] == '#')
  332.     name++;
  333.   return name;
  334. }
  335.  
  336. /* Decode an `asm' spec for a declaration as a register name.
  337.    Return the register number, or -1 if nothing specified,
  338.    or -2 if the ASMSPEC is not `cc' or `memory' and is not recognized,
  339.    or -3 if ASMSPEC is `cc' and is not recognized,
  340.    or -4 if ASMSPEC is `memory' and is not recognized.
  341.    Accept an exact spelling or a decimal number.
  342.    Prefixes such as % are optional.  */
  343.  
  344. int
  345. decode_reg_name (asmspec)
  346.      char *asmspec;
  347. {
  348.   if (asmspec != 0)
  349.     {
  350.       int i;
  351.  
  352.       /* Get rid of confusing prefixes.  */
  353.       asmspec = strip_reg_name (asmspec);
  354.     
  355.       /* Allow a decimal number as a "register name".  */
  356.       for (i = strlen (asmspec) - 1; i >= 0; i--)
  357.     if (! (asmspec[i] >= '0' && asmspec[i] <= '9'))
  358.       break;
  359.       if (asmspec[0] != 0 && i < 0)
  360.     {
  361.       i = atoi (asmspec);
  362.       if (i < FIRST_PSEUDO_REGISTER && i >= 0)
  363.         return i;
  364.       else
  365.         return -2;
  366.     }
  367.  
  368.       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  369.     if (reg_names[i][0]
  370.         && ! strcmp (asmspec, strip_reg_name (reg_names[i])))
  371.       return i;
  372.  
  373. #ifdef ADDITIONAL_REGISTER_NAMES
  374.       {
  375.     static struct { char *name; int number; } table[]
  376.       = ADDITIONAL_REGISTER_NAMES;
  377.  
  378.     for (i = 0; i < sizeof (table) / sizeof (table[0]); i++)
  379.       if (! strcmp (asmspec, table[i].name))
  380.         return table[i].number;
  381.       }
  382. #endif /* ADDITIONAL_REGISTER_NAMES */
  383.  
  384.       if (!strcmp (asmspec, "memory"))
  385.     return -4;
  386.  
  387.       if (!strcmp (asmspec, "cc"))
  388.     return -3;
  389.  
  390.       return -2;
  391.     }
  392.  
  393.   return -1;
  394. }
  395.  
  396. /* Create the DECL_RTL for a declaration for a static or external variable
  397.    or static or external function.
  398.    ASMSPEC, if not 0, is the string which the user specified
  399.    as the assembler symbol name.
  400.    TOP_LEVEL is nonzero if this is a file-scope variable.
  401.  
  402.    This is never called for PARM_DECL nodes.  */
  403.  
  404. void
  405. make_decl_rtl (decl, asmspec, top_level)
  406.      tree decl;
  407.      char *asmspec;
  408.      int top_level;
  409. {
  410.   register char *name = 0;
  411.   int reg_number;
  412.  
  413.   if (output_bytecode)
  414.     {
  415.       bc_make_decl_rtl (decl, asmspec, top_level);
  416.       return;
  417.     }
  418.  
  419.   reg_number = decode_reg_name (asmspec);
  420.  
  421.   if (DECL_ASSEMBLER_NAME (decl) != NULL_TREE)
  422.     name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
  423.  
  424.   if (reg_number == -2)
  425.     {
  426.       /* ASMSPEC is given, and not the name of a register.  */
  427.       name = (char *) obstack_alloc (saveable_obstack,
  428.                      strlen (asmspec) + 2);
  429.       name[0] = '*';
  430.       strcpy (&name[1], asmspec);
  431.     }
  432.  
  433.   /* For a duplicate declaration, we can be called twice on the
  434.      same DECL node.  Don't discard the RTL already made.  */
  435.   if (DECL_RTL (decl) == 0)
  436.     {
  437.       DECL_RTL (decl) = 0;
  438.  
  439.       /* First detect errors in declaring global registers.  */
  440.       if (DECL_REGISTER (decl) && reg_number == -1)
  441.     error_with_decl (decl,
  442.              "register name not specified for `%s'");
  443.       else if (DECL_REGISTER (decl) && reg_number < 0)
  444.     error_with_decl (decl,
  445.              "invalid register name for `%s'");
  446.       else if ((reg_number >= 0 || reg_number == -3) && ! DECL_REGISTER (decl))
  447.     error_with_decl (decl,
  448.              "register name given for non-register variable `%s'");
  449.       else if (DECL_REGISTER (decl) && TREE_CODE (decl) == FUNCTION_DECL)
  450.     error ("function declared `register'");
  451.       else if (DECL_REGISTER (decl) && TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
  452.     error_with_decl (decl, "data type of `%s' isn't suitable for a register");
  453.       else if (DECL_REGISTER (decl)
  454.            && ! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl))))
  455.     error_with_decl (decl, "register number for `%s' isn't suitable for the data type");
  456.       /* Now handle properly declared static register variables.  */
  457.       else if (DECL_REGISTER (decl))
  458.     {
  459.       int nregs;
  460. #if 0 /* yylex should print the warning for this */
  461.       if (pedantic)
  462.         pedwarn ("ANSI C forbids global register variables");
  463. #endif
  464.       if (DECL_INITIAL (decl) != 0 && top_level)
  465.         {
  466.           DECL_INITIAL (decl) = 0;
  467.           error ("global register variable has initial value");
  468.         }
  469.       if (fixed_regs[reg_number] == 0
  470.           && function_defined && top_level)
  471.         error ("global register variable follows a function definition");
  472.       if (TREE_THIS_VOLATILE (decl))
  473.         warning ("volatile register variables don't work as you might wish");
  474.  
  475.       /* If the user specified one of the eliminables registers here,
  476.          e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
  477.          confused with that register and be eliminated.  Although this
  478.          usage is somewhat suspect, we nevertheless use the following
  479.          kludge to avoid setting DECL_RTL to frame_pointer_rtx.  */
  480.  
  481.       DECL_RTL (decl)
  482.         = gen_rtx (REG, DECL_MODE (decl), FIRST_PSEUDO_REGISTER);
  483.       REGNO (DECL_RTL (decl)) = reg_number;
  484.       REG_USERVAR_P (DECL_RTL (decl)) = 1;
  485.  
  486.       if (top_level)
  487.         {
  488.           /* Make this register global, so not usable for anything
  489.          else.  */
  490.           nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl));
  491.           while (nregs > 0)
  492.         globalize_reg (reg_number + --nregs);
  493.         }
  494.     }
  495.       /* Specifying a section attribute on an uninitialized variable does not
  496.      (and cannot) cause it to be put in the given section.  The linker
  497.      can only put initialized objects in specific sections, everything
  498.      else goes in bss for the linker to sort out later (otherwise the
  499.      linker would give a duplicate definition error for each compilation
  500.      unit that behaved thusly).  So warn the user.  */
  501.       else if (TREE_CODE (decl) == VAR_DECL
  502.            && DECL_SECTION_NAME (decl) != NULL_TREE
  503.            && DECL_INITIAL (decl) == NULL_TREE)
  504.     {
  505.       warning_with_decl (decl,
  506.                  "section attribute ignored for uninitialized variable `%s'");
  507.       /* Remove the section name so subsequent declarations won't see it.
  508.          We are ignoring it, remember.  */
  509.       DECL_SECTION_NAME (decl) = NULL_TREE;
  510.     }
  511.  
  512.       /* Now handle ordinary static variables and functions (in memory).
  513.      Also handle vars declared register invalidly.  */
  514.       if (DECL_RTL (decl) == 0)
  515.     {
  516.       /* Can't use just the variable's own name for a variable
  517.          whose scope is less than the whole file.
  518.          Concatenate a distinguishing number.  */
  519.       if (!top_level && !DECL_EXTERNAL (decl) && asmspec == 0)
  520.         {
  521.           char *label;
  522.  
  523.           ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
  524.           name = obstack_copy0 (saveable_obstack, label, strlen (label));
  525.           var_labelno++;
  526.         }
  527.  
  528.       if (name == 0)
  529.         abort ();
  530.  
  531.       DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl),
  532.                      gen_rtx (SYMBOL_REF, Pmode, name));
  533.  
  534.       /* If this variable is to be treated as volatile, show its
  535.          tree node has side effects.  If it has side effects, either
  536.          because of this test or from TREE_THIS_VOLATILE also
  537.          being set, show the MEM is volatile.  */
  538.       if (flag_volatile_global && TREE_CODE (decl) == VAR_DECL
  539.           && TREE_PUBLIC (decl))
  540.         TREE_SIDE_EFFECTS (decl) = 1;
  541.       if (TREE_SIDE_EFFECTS (decl))
  542.         MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
  543.  
  544.       if (TREE_READONLY (decl))
  545.         RTX_UNCHANGING_P (DECL_RTL (decl)) = 1;
  546.       MEM_IN_STRUCT_P (DECL_RTL (decl))
  547.         = AGGREGATE_TYPE_P (TREE_TYPE (decl));
  548.  
  549.       /* Optionally set flags or add text to the name to record information
  550.          such as that it is a function name.
  551.          If the name is changed, the macro ASM_OUTPUT_LABELREF
  552.          will have to know how to strip this information.  */
  553. #ifdef ENCODE_SECTION_INFO
  554.       ENCODE_SECTION_INFO (decl);
  555. #endif
  556.     }
  557.     }
  558.   /* If the old RTL had the wrong mode, fix the mode.  */
  559.   else if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
  560.     {
  561.       rtx rtl = DECL_RTL (decl);
  562.       PUT_MODE (rtl, DECL_MODE (decl));
  563.     }
  564. }
  565.  
  566. /* Make the rtl for variable VAR be volatile.
  567.    Use this only for static variables.  */
  568.  
  569. void
  570. make_var_volatile (var)
  571.      tree var;
  572. {
  573.   if (GET_CODE (DECL_RTL (var)) != MEM)
  574.     abort ();
  575.  
  576.   MEM_VOLATILE_P (DECL_RTL (var)) = 1;
  577. }
  578.  
  579. /* Output alignment directive to align for constant expression EXP.  */
  580.  
  581. void
  582. assemble_constant_align (exp)
  583.      tree exp;
  584. {
  585.   int align;
  586.  
  587.   /* Align the location counter as required by EXP's data type.  */
  588.   align = TYPE_ALIGN (TREE_TYPE (exp));
  589. #ifdef CONSTANT_ALIGNMENT
  590.   align = CONSTANT_ALIGNMENT (exp, align);
  591. #endif
  592.  
  593.   if (align > BITS_PER_UNIT)
  594.     ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
  595. }
  596.  
  597. /* Output a string of literal assembler code
  598.    for an `asm' keyword used between functions.  */
  599.  
  600. void
  601. assemble_asm (string)
  602.      tree string;
  603. {
  604.   if (output_bytecode)
  605.     {
  606.       error ("asm statements not allowed in interpreter");
  607.       return;
  608.     }
  609.  
  610.   app_enable ();
  611.  
  612.   if (TREE_CODE (string) == ADDR_EXPR)
  613.     string = TREE_OPERAND (string, 0);
  614.  
  615.   fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
  616. }
  617.  
  618. #if 0 /* This should no longer be needed, because
  619.      flag_gnu_linker should be 0 on these systems,
  620.      which should prevent any output
  621.      if ASM_OUTPUT_CONSTRUCTOR and ASM_OUTPUT_DESTRUCTOR are absent.  */
  622. #if !(defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER))
  623. #ifndef ASM_OUTPUT_CONSTRUCTOR
  624. #define ASM_OUTPUT_CONSTRUCTOR(file, name)
  625. #endif
  626. #ifndef ASM_OUTPUT_DESTRUCTOR
  627. #define ASM_OUTPUT_DESTRUCTOR(file, name)
  628. #endif
  629. #endif
  630. #endif /* 0 */
  631.  
  632. /* Record an element in the table of global destructors.
  633.    How this is done depends on what sort of assembler and linker
  634.    are in use.
  635.  
  636.    NAME should be the name of a global function to be called
  637.    at exit time.  This name is output using assemble_name.  */
  638.  
  639. void
  640. assemble_destructor (name)
  641.      char *name;
  642. {
  643. #ifdef ASM_OUTPUT_DESTRUCTOR
  644.   ASM_OUTPUT_DESTRUCTOR (asm_out_file, name);
  645. #else
  646.   if (flag_gnu_linker)
  647.     {
  648.       /* Now tell GNU LD that this is part of the static destructor set.  */
  649.       /* This code works for any machine provided you use GNU as/ld.  */
  650.       fprintf (asm_out_file, "%s \"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP);
  651.       assemble_name (asm_out_file, name);
  652.       fputc ('\n', asm_out_file);
  653.     }
  654. #endif
  655. }
  656.  
  657. /* Likewise for global constructors.  */
  658.  
  659. void
  660. assemble_constructor (name)
  661.      char *name;
  662. {
  663. #ifdef ASM_OUTPUT_CONSTRUCTOR
  664.   ASM_OUTPUT_CONSTRUCTOR (asm_out_file, name);
  665. #else
  666.   if (flag_gnu_linker)
  667.     {
  668.       /* Now tell GNU LD that this is part of the static constructor set.  */
  669.       /* This code works for any machine provided you use GNU as/ld.  */
  670.       fprintf (asm_out_file, "%s \"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP);
  671.       assemble_name (asm_out_file, name);
  672.       fputc ('\n', asm_out_file);
  673.     }
  674. #endif
  675. }
  676.  
  677. /* Likewise for entries we want to record for garbage collection.
  678.    Garbage collection is still under development.  */
  679.  
  680. void
  681. assemble_gc_entry (name)
  682.      char *name;
  683. {
  684. #ifdef ASM_OUTPUT_GC_ENTRY
  685.   ASM_OUTPUT_GC_ENTRY (asm_out_file, name);
  686. #else
  687.   if (flag_gnu_linker)
  688.     {
  689.       /* Now tell GNU LD that this is part of the static constructor set.  */
  690.       fprintf (asm_out_file, "%s \"___PTR_LIST__\",22,0,0,", ASM_STABS_OP);
  691.       assemble_name (asm_out_file, name);
  692.       fputc ('\n', asm_out_file);
  693.     }
  694. #endif
  695. }
  696.  
  697. /* Output assembler code for the constant pool of a function and associated
  698.    with defining the name of the function.  DECL describes the function.
  699.    NAME is the function's name.  For the constant pool, we use the current
  700.    constant pool data.  */
  701.  
  702. void
  703. assemble_start_function (decl, fnname)
  704.      tree decl;
  705.      char *fnname;
  706. {
  707.   int align;
  708.  
  709.   /* The following code does not need preprocessing in the assembler.  */
  710.  
  711.   app_disable ();
  712.  
  713.   output_constant_pool (fnname, decl);
  714.  
  715.   if (IN_NAMED_SECTION (decl))
  716.     named_section (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)));
  717.   else
  718.     text_section ();
  719.  
  720.   /* Tell assembler to move to target machine's alignment for functions.  */
  721.   align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
  722.   if (align > 0)
  723.     {
  724.       if (output_bytecode)
  725.     BC_OUTPUT_ALIGN (asm_out_file, align);
  726.       else
  727.     ASM_OUTPUT_ALIGN (asm_out_file, align);
  728.     }
  729.  
  730. #ifdef ASM_OUTPUT_FUNCTION_PREFIX
  731.   ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
  732. #endif
  733.  
  734. #ifdef SDB_DEBUGGING_INFO
  735.   /* Output SDB definition of the function.  */
  736.   if (write_symbols == SDB_DEBUG)
  737.     sdbout_mark_begin_function ();
  738. #endif
  739.  
  740. #ifdef DBX_DEBUGGING_INFO
  741.   /* Output DBX definition of the function.  */
  742.   if (write_symbols == DBX_DEBUG)
  743.     dbxout_begin_function (decl);
  744. #endif
  745.  
  746.   /* Make function name accessible from other files, if appropriate.  */
  747.  
  748.   if (TREE_PUBLIC (decl))
  749.     {
  750.       if (!first_global_object_name)
  751.     STRIP_NAME_ENCODING (first_global_object_name, fnname);
  752.       if (output_bytecode)
  753.     BC_GLOBALIZE_LABEL (asm_out_file, fnname);
  754.       else
  755.     ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
  756.     }
  757.  
  758.   /* Do any machine/system dependent processing of the function name */
  759. #ifdef ASM_DECLARE_FUNCTION_NAME
  760.   ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
  761. #else
  762.   /* Standard thing is just output label for the function.  */
  763.   if (output_bytecode)
  764.     BC_OUTPUT_LABEL (asm_out_file, fnname);
  765.   else
  766.     ASM_OUTPUT_LABEL (asm_out_file, fnname);
  767. #endif /* ASM_DECLARE_FUNCTION_NAME */
  768. }
  769.  
  770. /* Output assembler code associated with defining the size of the
  771.    function.  DECL describes the function.  NAME is the function's name.  */
  772.  
  773. void
  774. assemble_end_function (decl, fnname)
  775.      tree decl;
  776.      char *fnname;
  777. {
  778. #ifdef ASM_DECLARE_FUNCTION_SIZE
  779.   ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
  780. #endif
  781. }
  782.  
  783. /* Assemble code to leave SIZE bytes of zeros.  */
  784.  
  785. void
  786. assemble_zeros (size)
  787.      int size;
  788. {
  789.   if (output_bytecode)
  790.     {
  791.       bc_emit_const_skip (size);
  792.       return;
  793.     }
  794.  
  795. #ifdef ASM_NO_SKIP_IN_TEXT
  796.   /* The `space' pseudo in the text section outputs nop insns rather than 0s,
  797.      so we must output 0s explicitly in the text section.  */
  798.   if (ASM_NO_SKIP_IN_TEXT && in_text_section ())
  799.     {
  800.       int i;
  801.  
  802.       for (i = 0; i < size - 20; i += 20)
  803.     {
  804. #ifdef ASM_BYTE_OP
  805.       fprintf (asm_out_file,
  806.            "%s 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n", ASM_BYTE_OP);
  807. #else
  808.       fprintf (asm_out_file,
  809.            "\tbyte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n");
  810. #endif
  811.     }
  812.       if (i < size)
  813.         {
  814. #ifdef ASM_BYTE_OP
  815.       fprintf (asm_out_file, "%s 0", ASM_BYTE_OP);
  816. #else
  817.       fprintf (asm_out_file, "\tbyte 0");
  818. #endif
  819.       i++;
  820.       for (; i < size; i++)
  821.         fprintf (asm_out_file, ",0");
  822.       fprintf (asm_out_file, "\n");
  823.     }
  824.     }
  825.   else
  826. #endif
  827.     if (size > 0)
  828.       {
  829.     if (output_bytecode)
  830.       BC_OUTPUT_SKIP (asm_out_file, size);
  831.     else
  832.       ASM_OUTPUT_SKIP (asm_out_file, size);
  833.       }
  834. }
  835.  
  836. /* Assemble an alignment pseudo op for an ALIGN-bit boundary.  */
  837.  
  838. void
  839. assemble_align (align)
  840.      int align;
  841. {
  842.   if (align > BITS_PER_UNIT)
  843.     ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
  844. }
  845.  
  846. /* Assemble a string constant with the specified C string as contents.  */
  847.  
  848. void
  849. assemble_string (p, size)
  850.      char *p;
  851.      int size;
  852. {
  853.   register int i;
  854.   int pos = 0;
  855.   int maximum = 2000;
  856.  
  857.   if (output_bytecode)
  858.     {
  859.       bc_emit (p, size);
  860.       return;
  861.     }
  862.  
  863.   /* If the string is very long, split it up.  */
  864.  
  865.   while (pos < size)
  866.     {
  867.       int thissize = size - pos;
  868.       if (thissize > maximum)
  869.     thissize = maximum;
  870.  
  871.       if (output_bytecode)
  872.     bc_output_ascii (asm_out_file, p, thissize);
  873.       else
  874.     {
  875.       ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
  876.     }
  877.  
  878.       pos += thissize;
  879.       p += thissize;
  880.     }
  881. }
  882.  
  883. static void
  884. bc_output_ascii (file, p, size)
  885.      FILE *file;
  886.      char *p;
  887.      int size;
  888. {
  889.   BC_OUTPUT_ASCII (file, p, size);
  890. }
  891.  
  892. /* Assemble everything that is needed for a variable or function declaration.
  893.    Not used for automatic variables, and not used for function definitions.
  894.    Should not be called for variables of incomplete structure type.
  895.  
  896.    TOP_LEVEL is nonzero if this variable has file scope.
  897.    AT_END is nonzero if this is the special handling, at end of compilation,
  898.    to define things that have had only tentative definitions.
  899.    DONT_OUTPUT_DATA if nonzero means don't actually output the
  900.    initial value (that will be done by the caller).  */
  901.  
  902. void
  903. assemble_variable (decl, top_level, at_end, dont_output_data)
  904.      tree decl;
  905.      int top_level;
  906.      int at_end;
  907. {
  908.   register char *name;
  909.   int align;
  910.   tree size_tree;
  911.   int reloc = 0;
  912.   enum in_section saved_in_section;
  913.  
  914.   last_assemble_variable_decl = 0;
  915.  
  916.   if (output_bytecode)
  917.     return;
  918.  
  919.   if (GET_CODE (DECL_RTL (decl)) == REG)
  920.     {
  921.       /* Do output symbol info for global register variables, but do nothing
  922.      else for them.  */
  923.  
  924.       if (TREE_ASM_WRITTEN (decl))
  925.     return;
  926.       TREE_ASM_WRITTEN (decl) = 1;
  927.  
  928.       if (!output_bytecode)
  929.     {
  930. #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
  931.       /* File-scope global variables are output here.  */
  932.       if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
  933.           && top_level)
  934.         dbxout_symbol (decl, 0);
  935. #endif
  936. #ifdef SDB_DEBUGGING_INFO
  937.       if (write_symbols == SDB_DEBUG && top_level
  938.           /* Leave initialized global vars for end of compilation;
  939.          see comment in compile_file.  */
  940.           && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
  941.         sdbout_symbol (decl, 0);
  942. #endif
  943.     }
  944.  
  945.       /* Don't output any DWARF debugging information for variables here.
  946.      In the case of local variables, the information for them is output
  947.      when we do our recursive traversal of the tree representation for
  948.      the entire containing function.  In the case of file-scope variables,
  949.      we output information for all of them at the very end of compilation
  950.      while we are doing our final traversal of the chain of file-scope
  951.      declarations.  */
  952.  
  953.       return;
  954.     }
  955.  
  956.   /* Normally no need to say anything here for external references,
  957.      since assemble_external is called by the langauge-specific code
  958.      when a declaration is first seen.  */
  959.  
  960.   if (DECL_EXTERNAL (decl))
  961.     return;
  962.  
  963.   /* Output no assembler code for a function declaration.
  964.      Only definitions of functions output anything.  */
  965.  
  966.   if (TREE_CODE (decl) == FUNCTION_DECL)
  967.     return;
  968.  
  969.   /* If type was incomplete when the variable was declared,
  970.      see if it is complete now.  */
  971.  
  972.   if (DECL_SIZE (decl) == 0)
  973.     layout_decl (decl, 0);
  974.  
  975.   /* Still incomplete => don't allocate it; treat the tentative defn
  976.      (which is what it must have been) as an `extern' reference.  */
  977.  
  978.   if (!dont_output_data && DECL_SIZE (decl) == 0)
  979.     {
  980.       error_with_file_and_line (DECL_SOURCE_FILE (decl),
  981.                 DECL_SOURCE_LINE (decl),
  982.                 "storage size of `%s' isn't known",
  983.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  984.       TREE_ASM_WRITTEN (decl) = 1;
  985.       return;
  986.     }
  987.  
  988.   /* The first declaration of a variable that comes through this function
  989.      decides whether it is global (in C, has external linkage)
  990.      or local (in C, has internal linkage).  So do nothing more
  991.      if this function has already run.  */
  992.  
  993.   if (TREE_ASM_WRITTEN (decl))
  994.     return;
  995.  
  996.   TREE_ASM_WRITTEN (decl) = 1;
  997.  
  998.   /* If storage size is erroneously variable, just continue.
  999.      Error message was already made.  */
  1000.  
  1001.   if (DECL_SIZE (decl))
  1002.     {
  1003.       if (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
  1004.     goto finish;
  1005.  
  1006.       app_disable ();
  1007.  
  1008.       /* This is better than explicit arithmetic, since it avoids overflow.  */
  1009.       size_tree = size_binop (CEIL_DIV_EXPR,
  1010.                   DECL_SIZE (decl), size_int (BITS_PER_UNIT));
  1011.  
  1012.       if (TREE_INT_CST_HIGH (size_tree) != 0)
  1013.     {
  1014.       error_with_decl (decl, "size of variable `%s' is too large");
  1015.       goto finish;
  1016.     }
  1017.     }
  1018.  
  1019.   name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
  1020.  
  1021.   /* Handle uninitialized definitions.  */
  1022.  
  1023.   /* ANSI specifies that a tentative definition which is not merged with
  1024.      a non-tentative definition behaves exactly like a definition with an
  1025.      initializer equal to zero.  (Section 3.7.2)
  1026.      -fno-common gives strict ANSI behavior.  Usually you don't want it.
  1027.      This matters only for variables with external linkage.  */
  1028.   if ((! flag_no_common || ! TREE_PUBLIC (decl))
  1029.       && DECL_COMMON (decl)
  1030.       && ! dont_output_data
  1031.       && (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
  1032.     {
  1033.       int size = TREE_INT_CST_LOW (size_tree);
  1034.       int rounded = size;
  1035.  
  1036.       if (TREE_INT_CST_HIGH (size_tree) != 0)
  1037.     error_with_decl (decl, "size of variable `%s' is too large");
  1038.       /* Don't allocate zero bytes of common,
  1039.      since that means "undefined external" in the linker.  */
  1040.       if (size == 0) rounded = 1;
  1041.       /* Round size up to multiple of BIGGEST_ALIGNMENT bits
  1042.      so that each uninitialized object starts on such a boundary.  */
  1043.       rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
  1044.       rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  1045.          * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
  1046.  
  1047. #ifdef DBX_DEBUGGING_INFO
  1048.       /* File-scope global variables are output here.  */
  1049.       if (write_symbols == DBX_DEBUG && top_level)
  1050.     dbxout_symbol (decl, 0);
  1051. #endif
  1052. #ifdef SDB_DEBUGGING_INFO
  1053.       if (write_symbols == SDB_DEBUG && top_level
  1054.       /* Leave initialized global vars for end of compilation;
  1055.          see comment in compile_file.  */
  1056.       && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
  1057.     sdbout_symbol (decl, 0);
  1058. #endif
  1059.  
  1060.       /* Don't output any DWARF debugging information for variables here.
  1061.      In the case of local variables, the information for them is output
  1062.      when we do our recursive traversal of the tree representation for
  1063.      the entire containing function.  In the case of file-scope variables,
  1064.      we output information for all of them at the very end of compilation
  1065.      while we are doing our final traversal of the chain of file-scope
  1066.      declarations.  */
  1067.  
  1068. #if 0
  1069.       if (flag_shared_data)
  1070.     data_section ();
  1071. #endif
  1072.       if (TREE_PUBLIC (decl))
  1073.     {
  1074. #ifdef ASM_OUTPUT_SHARED_COMMON
  1075.       if (flag_shared_data)
  1076.         ASM_OUTPUT_SHARED_COMMON (asm_out_file, name, size, rounded);
  1077.       else
  1078. #endif
  1079.         if (output_bytecode)
  1080.           {
  1081.         BC_OUTPUT_COMMON (asm_out_file, name, size, rounded);
  1082.           }
  1083.         else
  1084.           {
  1085. #ifdef ASM_OUTPUT_ALIGNED_COMMON
  1086.         ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size,
  1087.                        DECL_ALIGN (decl));
  1088. #else
  1089.         ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
  1090. #endif
  1091.           }
  1092.     }
  1093.       else
  1094.     {
  1095. #ifdef ASM_OUTPUT_SHARED_LOCAL
  1096.       if (flag_shared_data)
  1097.         ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
  1098.       else
  1099. #endif
  1100.         if (output_bytecode)
  1101.           {
  1102.         BC_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
  1103.           }
  1104.         else
  1105.           {
  1106. #ifdef ASM_OUTPUT_ALIGNED_LOCAL
  1107.         ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size,
  1108.                       DECL_ALIGN (decl));
  1109. #else
  1110.         ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
  1111. #endif
  1112.           }
  1113.     }
  1114.       goto finish;
  1115.     }
  1116.  
  1117.   /* Handle initialized definitions.  */
  1118.  
  1119.   /* First make the assembler name(s) global if appropriate.  */
  1120.   if (TREE_PUBLIC (decl) && DECL_NAME (decl))
  1121.     {
  1122.       if (!first_global_object_name)
  1123.     STRIP_NAME_ENCODING(first_global_object_name, name);
  1124.       ASM_GLOBALIZE_LABEL (asm_out_file, name);
  1125.     }
  1126. #if 0
  1127.   for (d = equivalents; d; d = TREE_CHAIN (d))
  1128.     {
  1129.       tree e = TREE_VALUE (d);
  1130.       if (TREE_PUBLIC (e) && DECL_NAME (e))
  1131.     ASM_GLOBALIZE_LABEL (asm_out_file,
  1132.                  XSTR (XEXP (DECL_RTL (e), 0), 0));
  1133.     }
  1134. #endif
  1135.  
  1136.   /* Output any data that we will need to use the address of.  */
  1137.   if (DECL_INITIAL (decl) == error_mark_node)
  1138.     reloc = contains_pointers_p (TREE_TYPE (decl));
  1139.   else if (DECL_INITIAL (decl))
  1140.     reloc = output_addressed_constants (DECL_INITIAL (decl));
  1141.  
  1142.   /* Switch to the proper section for this data.  */
  1143.   if (IN_NAMED_SECTION (decl))
  1144.     named_section (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)));
  1145.   else
  1146.     {
  1147.       /* C++ can have const variables that get initialized from constructors,
  1148.      and thus can not be in a readonly section.  We prevent this by
  1149.      verifying that the initial value is constant for objects put in a
  1150.      readonly section.
  1151.  
  1152.      error_mark_node is used by the C front end to indicate that the
  1153.      initializer has not been seen yet.  In this case, we assume that
  1154.      the initializer must be constant.  */
  1155. #ifdef SELECT_SECTION
  1156.       SELECT_SECTION (decl, reloc);
  1157. #else
  1158.       if (TREE_READONLY (decl)
  1159.       && ! TREE_THIS_VOLATILE (decl)
  1160.       && DECL_INITIAL (decl)
  1161.       && (DECL_INITIAL (decl) == error_mark_node
  1162.           || TREE_CONSTANT (DECL_INITIAL (decl)))
  1163.       && ! (flag_pic && reloc))
  1164.     readonly_data_section ();
  1165.       else
  1166.     data_section ();
  1167. #endif
  1168.     }
  1169.  
  1170.   /* dbxout.c needs to know this.  */
  1171.   if (in_text_section ())
  1172.     DECL_IN_TEXT_SECTION (decl) = 1;
  1173.  
  1174.   /* Record current section so we can restore it if dbxout.c clobbers it.  */
  1175.   saved_in_section = in_section;
  1176.  
  1177.   /* Output the dbx info now that we have chosen the section.  */
  1178.  
  1179. #ifdef DBX_DEBUGGING_INFO
  1180.   /* File-scope global variables are output here.  */
  1181.   if (write_symbols == DBX_DEBUG && top_level)
  1182.     dbxout_symbol (decl, 0);
  1183. #endif
  1184. #ifdef SDB_DEBUGGING_INFO
  1185.   if (write_symbols == SDB_DEBUG && top_level
  1186.       /* Leave initialized global vars for end of compilation;
  1187.      see comment in compile_file.  */
  1188.       && (TREE_PUBLIC (decl) == 0 || DECL_INITIAL (decl) == 0))
  1189.     sdbout_symbol (decl, 0);
  1190. #endif
  1191.  
  1192.   /* Don't output any DWARF debugging information for variables here.
  1193.      In the case of local variables, the information for them is output
  1194.      when we do our recursive traversal of the tree representation for
  1195.      the entire containing function.  In the case of file-scope variables,
  1196.      we output information for all of them at the very end of compilation
  1197.      while we are doing our final traversal of the chain of file-scope
  1198.      declarations.  */
  1199.  
  1200.   /* If the debugging output changed sections, reselect the section
  1201.      that's supposed to be selected.  */
  1202.   if (in_section != saved_in_section)
  1203.     {
  1204.       /* Switch to the proper section for this data.  */
  1205. #ifdef SELECT_SECTION
  1206.       SELECT_SECTION (decl, reloc);
  1207. #else
  1208.       if (TREE_READONLY (decl)
  1209.       && ! TREE_THIS_VOLATILE (decl)
  1210.       && DECL_INITIAL (decl)
  1211.       && (DECL_INITIAL (decl) == error_mark_node
  1212.           || TREE_CONSTANT (DECL_INITIAL (decl)))
  1213.       && ! (flag_pic && reloc))
  1214.     readonly_data_section ();
  1215.       else
  1216.     data_section ();
  1217. #endif
  1218.     }
  1219.  
  1220.   /* Compute and output the alignment of this data.  */
  1221.  
  1222.   align = DECL_ALIGN (decl);
  1223.   /* In the case for initialing an array whose length isn't specified,
  1224.      where we have not yet been able to do the layout,
  1225.      figure out the proper alignment now.  */
  1226.   if (dont_output_data && DECL_SIZE (decl) == 0
  1227.       && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
  1228.     align = MAX (align, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
  1229.  
  1230.   /* Some object file formats have a maximum alignment which they support.
  1231.      In particular, a.out format supports a maximum alignment of 4.  */
  1232. #ifndef MAX_OFILE_ALIGNMENT
  1233. #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
  1234. #endif
  1235.   if (align > MAX_OFILE_ALIGNMENT)
  1236.     {
  1237.       warning_with_decl (decl,
  1238.       "alignment of `%s' is greater than maximum object file alignment");
  1239.       align = MAX_OFILE_ALIGNMENT;
  1240.     }
  1241. #ifdef DATA_ALIGNMENT
  1242.   /* On some machines, it is good to increase alignment sometimes.  */
  1243.   align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
  1244. #endif
  1245. #ifdef CONSTANT_ALIGNMENT
  1246.   if (DECL_INITIAL (decl))
  1247.     align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
  1248. #endif
  1249.  
  1250.   /* Reset the alignment in case we have made it tighter, so we can benefit
  1251.      from it in get_pointer_alignment.  */
  1252.   DECL_ALIGN (decl) = align;
  1253.  
  1254.   if (align > BITS_PER_UNIT)
  1255.     {
  1256.       if (output_bytecode)
  1257.     BC_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
  1258.       else
  1259.     ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
  1260.     }
  1261.  
  1262.   /* Do any machine/system dependent processing of the object.  */
  1263. #ifdef ASM_DECLARE_OBJECT_NAME
  1264.   last_assemble_variable_decl = decl;
  1265.   ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl);
  1266. #else
  1267.   /* Standard thing is just output label for the object.  */
  1268.   if (output_bytecode)
  1269.     BC_OUTPUT_LABEL (asm_out_file, name);
  1270.   else
  1271.     ASM_OUTPUT_LABEL (asm_out_file, name);
  1272. #endif /* ASM_DECLARE_OBJECT_NAME */
  1273.  
  1274.   if (!dont_output_data)
  1275.     {
  1276.       if (DECL_INITIAL (decl))
  1277.     /* Output the actual data.  */
  1278.     output_constant (DECL_INITIAL (decl),
  1279.              int_size_in_bytes (TREE_TYPE (decl)));
  1280.       else
  1281.     /* Leave space for it.  */
  1282.     assemble_zeros (int_size_in_bytes (TREE_TYPE (decl)));
  1283.     }
  1284.  
  1285.  finish:
  1286. #ifdef XCOFF_DEBUGGING_INFO
  1287.   /* Unfortunately, the IBM assembler cannot handle stabx before the actual
  1288.      declaration.  When something like ".stabx  "aa:S-2",aa,133,0" is emitted 
  1289.      and `aa' hasn't been output yet, the assembler generates a stab entry with
  1290.      a value of zero, in addition to creating an unnecessary external entry
  1291.      for `aa'.  Hence, we must postpone dbxout_symbol to here at the end.  */
  1292.  
  1293.   /* File-scope global variables are output here.  */
  1294.   if (write_symbols == XCOFF_DEBUG && top_level)
  1295.     {
  1296.       saved_in_section = in_section;
  1297.  
  1298.       dbxout_symbol (decl, 0);
  1299.  
  1300.       if (in_section != saved_in_section)
  1301.     {
  1302.       /* Switch to the proper section for this data.  */
  1303. #ifdef SELECT_SECTION
  1304.       SELECT_SECTION (decl, reloc);
  1305. #else
  1306.       if (TREE_READONLY (decl)
  1307.           && ! TREE_THIS_VOLATILE (decl)
  1308.           && DECL_INITIAL (decl)
  1309.           && (DECL_INITIAL (decl) == error_mark_node
  1310.           || TREE_CONSTANT (DECL_INITIAL (decl)))
  1311.           && ! (flag_pic && reloc))
  1312.         readonly_data_section ();
  1313.       else
  1314.         data_section ();
  1315. #endif
  1316.     }
  1317.     }
  1318. #else
  1319.   /* There must be a statement after a label.  */
  1320.   ;
  1321. #endif
  1322. }
  1323.  
  1324. /* Return 1 if type TYPE contains any pointers.  */
  1325.  
  1326. static int
  1327. contains_pointers_p (type)
  1328.      tree type;
  1329. {
  1330.   switch (TREE_CODE (type))
  1331.     {
  1332.     case POINTER_TYPE:
  1333.     case REFERENCE_TYPE:
  1334.       /* I'm not sure whether OFFSET_TYPE needs this treatment,
  1335.      so I'll play safe and return 1.  */
  1336.     case OFFSET_TYPE:
  1337.       return 1;
  1338.  
  1339.     case RECORD_TYPE:
  1340.     case UNION_TYPE:
  1341.     case QUAL_UNION_TYPE:
  1342.       {
  1343.     tree fields;
  1344.     /* For a type that has fields, see if the fields have pointers.  */
  1345.     for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
  1346.       if (TREE_CODE (fields) == FIELD_DECL
  1347.           && contains_pointers_p (TREE_TYPE (fields)))
  1348.         return 1;
  1349.     return 0;
  1350.       }
  1351.  
  1352.     case ARRAY_TYPE:
  1353.       /* An array type contains pointers if its element type does.  */
  1354.       return contains_pointers_p (TREE_TYPE (type));
  1355.  
  1356.     default:
  1357.       return 0;
  1358.     }
  1359. }
  1360.  
  1361. /* Output text storage for constructor CONSTR.  Returns rtx of
  1362.    storage. */
  1363.  
  1364. rtx
  1365. bc_output_constructor (constr)
  1366.   tree constr;
  1367. {
  1368.   int i;
  1369.  
  1370.   /* Must always be a literal; non-literal constructors are handled
  1371.      differently. */
  1372.  
  1373.   if (!TREE_CONSTANT (constr))
  1374.     abort ();
  1375.  
  1376.   /* Always const */
  1377.   text_section ();
  1378.  
  1379.   /* Align */
  1380.   for (i = 0; TYPE_ALIGN (constr) >= BITS_PER_UNIT << (i + 1); i++);
  1381.   if (i > 0)
  1382.     BC_OUTPUT_ALIGN (asm_out_file, i);
  1383.  
  1384.   /* Output data */
  1385.   output_constant (constr, int_size_in_bytes (TREE_TYPE (constr)));
  1386. }
  1387.  
  1388.  
  1389. /* Create storage for constructor CONSTR. */
  1390.  
  1391. void
  1392. bc_output_data_constructor (constr)
  1393.     tree constr;
  1394. {
  1395.   int i;
  1396.  
  1397.   /* Put in data section */
  1398.   data_section ();
  1399.  
  1400.   /* Align */
  1401.   for (i = 0; TYPE_ALIGN (constr) >= BITS_PER_UNIT << (i + 1); i++);
  1402.   if (i > 0)
  1403.     BC_OUTPUT_ALIGN (asm_out_file, i);
  1404.  
  1405.   /* The constructor is filled in at runtime. */
  1406.   BC_OUTPUT_SKIP (asm_out_file, int_size_in_bytes (TREE_TYPE (constr)));
  1407. }
  1408.  
  1409.  
  1410. /* Output something to declare an external symbol to the assembler.
  1411.    (Most assemblers don't need this, so we normally output nothing.)
  1412.    Do nothing if DECL is not external.  */
  1413.  
  1414. void
  1415. assemble_external (decl)
  1416.      tree decl;
  1417. {
  1418.   if (output_bytecode)
  1419.     return;
  1420.  
  1421. #ifdef ASM_OUTPUT_EXTERNAL
  1422.   if (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd'
  1423.       && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
  1424.     {
  1425.       rtx rtl = DECL_RTL (decl);
  1426.  
  1427.       if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF
  1428.       && ! SYMBOL_REF_USED (XEXP (rtl, 0)))
  1429.     {
  1430.       /* Some systems do require some output.  */
  1431.       SYMBOL_REF_USED (XEXP (rtl, 0)) = 1;
  1432.       ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
  1433.     }
  1434.     }
  1435. #endif
  1436. }
  1437.  
  1438. /* Similar, for calling a library function FUN.  */
  1439.  
  1440. void
  1441. assemble_external_libcall (fun)
  1442.      rtx fun;
  1443. {
  1444. #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
  1445.   if (!output_bytecode)
  1446.     {
  1447.       /* Declare library function name external when first used, if nec.  */
  1448.       if (! SYMBOL_REF_USED (fun))
  1449.     {
  1450.       SYMBOL_REF_USED (fun) = 1;
  1451.       ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun);
  1452.     }
  1453.     }
  1454. #endif
  1455. }
  1456.  
  1457. /* Declare the label NAME global.  */
  1458.  
  1459. void
  1460. assemble_global (name)
  1461.      char *name;
  1462. {
  1463.   ASM_GLOBALIZE_LABEL (asm_out_file, name);
  1464. }
  1465.  
  1466. /* Assemble a label named NAME.  */
  1467.  
  1468. void
  1469. assemble_label (name)
  1470.      char *name;
  1471. {
  1472.   if (output_bytecode)
  1473.     BC_OUTPUT_LABEL (asm_out_file, name);
  1474.   else
  1475.     ASM_OUTPUT_LABEL (asm_out_file, name);
  1476. }
  1477.  
  1478. /* Output to FILE a reference to the assembler name of a C-level name NAME.
  1479.    If NAME starts with a *, the rest of NAME is output verbatim.
  1480.    Otherwise NAME is transformed in an implementation-defined way
  1481.    (usually by the addition of an underscore).
  1482.    Many macros in the tm file are defined to call this function.  */
  1483.  
  1484. void
  1485. assemble_name (file, name)
  1486.      FILE *file;
  1487.      char *name;
  1488. {
  1489.   char *real_name;
  1490.  
  1491.   STRIP_NAME_ENCODING (real_name, name);
  1492.   TREE_SYMBOL_REFERENCED (get_identifier (real_name)) = 1;
  1493.  
  1494.   if (name[0] == '*')
  1495.     {
  1496.       if (output_bytecode)
  1497.     bc_emit_labelref (name);
  1498.       else
  1499.     fputs (&name[1], file);
  1500.     }
  1501.   else
  1502.     {
  1503.       if (output_bytecode)
  1504.     BC_OUTPUT_LABELREF (file, name);
  1505.       else
  1506.     ASM_OUTPUT_LABELREF (file, name);
  1507.     }
  1508. }
  1509.  
  1510. /* Allocate SIZE bytes writable static space with a gensym name
  1511.    and return an RTX to refer to its address.  */
  1512.  
  1513. rtx
  1514. assemble_static_space (size)
  1515.      int size;
  1516. {
  1517.   char name[12];
  1518.   char *namestring;
  1519.   rtx x;
  1520.   /* Round size up to multiple of BIGGEST_ALIGNMENT bits
  1521.      so that each uninitialized object starts on such a boundary.  */
  1522.   int rounded = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
  1523.          / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  1524.          * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
  1525.  
  1526. #if 0
  1527.   if (flag_shared_data)
  1528.     data_section ();
  1529. #endif
  1530.  
  1531.   ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
  1532.   ++const_labelno;
  1533.  
  1534.   namestring = (char *) obstack_alloc (saveable_obstack,
  1535.                        strlen (name) + 2);
  1536.   strcpy (namestring, name);
  1537.  
  1538.   if (output_bytecode)
  1539.     x = bc_gen_rtx (namestring, 0, (struct bc_label *) 0);
  1540.   else
  1541.     x = gen_rtx (SYMBOL_REF, Pmode, namestring);
  1542.  
  1543.   if (output_bytecode)
  1544.     {
  1545.       BC_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
  1546.     }
  1547.   else
  1548.     {
  1549. #ifdef ASM_OUTPUT_ALIGNED_LOCAL
  1550.       ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT);
  1551. #else
  1552.       ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
  1553. #endif
  1554.     }
  1555.   return x;
  1556. }
  1557.  
  1558. /* Assemble the static constant template for function entry trampolines.
  1559.    This is done at most once per compilation.
  1560.    Returns an RTX for the address of the template.  */
  1561.  
  1562. rtx
  1563. assemble_trampoline_template ()
  1564. {
  1565.   char label[256];
  1566.   char *name;
  1567.   int align;
  1568.  
  1569.   /* Shouldn't get here */
  1570.   if (output_bytecode)
  1571.     abort ();
  1572.  
  1573.   /* By default, put trampoline templates in read-only data section.  */
  1574.  
  1575. #ifdef TRAMPOLINE_SECTION
  1576.   TRAMPOLINE_SECTION ();
  1577. #else
  1578.   readonly_data_section ();
  1579. #endif
  1580.  
  1581.   /* Write the assembler code to define one.  */
  1582.   align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
  1583.   if (align > 0)
  1584.     ASM_OUTPUT_ALIGN (asm_out_file, align);
  1585.  
  1586.   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LTRAMP", 0);
  1587.   TRAMPOLINE_TEMPLATE (asm_out_file);
  1588.  
  1589.   /* Record the rtl to refer to it.  */
  1590.   ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
  1591.   name
  1592.     = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
  1593.   return gen_rtx (SYMBOL_REF, Pmode, name);
  1594. }
  1595.  
  1596. /* Assemble the integer constant X into an object of SIZE bytes.
  1597.    X must be either a CONST_INT or CONST_DOUBLE.
  1598.  
  1599.    Return 1 if we were able to output the constant, otherwise 0.  If FORCE is
  1600.    non-zero, abort if we can't output the constant.  */
  1601.  
  1602. int
  1603. assemble_integer (x, size, force)
  1604.      rtx x;
  1605.      int size;
  1606.      int force;
  1607. {
  1608.   /* First try to use the standard 1, 2, 4, 8, and 16 byte
  1609.      ASM_OUTPUT... macros. */
  1610.  
  1611.   switch (size)
  1612.     {
  1613. #ifdef ASM_OUTPUT_CHAR
  1614.     case 1:
  1615.       ASM_OUTPUT_CHAR (asm_out_file, x);
  1616.       return 1;
  1617. #endif
  1618.  
  1619. #ifdef ASM_OUTPUT_SHORT
  1620.     case 2:
  1621.       ASM_OUTPUT_SHORT (asm_out_file, x);
  1622.       return 1;
  1623. #endif
  1624.  
  1625. #ifdef ASM_OUTPUT_INT
  1626.     case 4:
  1627.       ASM_OUTPUT_INT (asm_out_file, x);
  1628.       return 1;
  1629. #endif
  1630.  
  1631. #ifdef ASM_OUTPUT_DOUBLE_INT
  1632.     case 8:
  1633.       ASM_OUTPUT_DOUBLE_INT (asm_out_file, x);
  1634.       return 1;
  1635. #endif
  1636.  
  1637. #ifdef ASM_OUTPUT_QUADRUPLE_INT
  1638.     case 16:
  1639.       ASM_OUTPUT_QUADRUPLE_INT (asm_out_file, x);
  1640.       return 1;
  1641. #endif
  1642.     }
  1643.  
  1644.   /* If we couldn't do it that way, there are two other possibilities: First,
  1645.      if the machine can output an explicit byte and this is a 1 byte constant,
  1646.      we can use ASM_OUTPUT_BYTE.  */
  1647.  
  1648. #ifdef ASM_OUTPUT_BYTE
  1649.   if (size == 1 && GET_CODE (x) == CONST_INT)
  1650.     {
  1651.       ASM_OUTPUT_BYTE (asm_out_file, INTVAL (x));
  1652.       return 1;
  1653.     }
  1654. #endif
  1655.  
  1656.   /* Finally, if SIZE is larger than a single word, try to output the constant
  1657.      one word at a time.  */
  1658.  
  1659.   if (size > UNITS_PER_WORD)
  1660.     {
  1661.       int i;
  1662.       enum machine_mode mode
  1663.     = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0);
  1664.       rtx word;
  1665.  
  1666.       for (i = 0; i < size / UNITS_PER_WORD; i++)
  1667.     {
  1668.       word = operand_subword (x, i, 0, mode);
  1669.  
  1670.       if (word == 0)
  1671.         break;
  1672.  
  1673.       if (! assemble_integer (word, UNITS_PER_WORD, 0))
  1674.         break;
  1675.     }
  1676.  
  1677.       if (i == size / UNITS_PER_WORD)
  1678.     return 1;
  1679.       /* If we output at least one word and then could not finish,
  1680.      there is no valid way to continue.  */
  1681.       if (i > 0)
  1682.     abort ();
  1683.     }
  1684.  
  1685.   if (force)
  1686.     abort ();
  1687.  
  1688.   return 0;
  1689. }
  1690.  
  1691. /* Assemble the floating-point constant D into an object of size MODE.  */
  1692.  
  1693. void
  1694. assemble_real (d, mode)
  1695.      REAL_VALUE_TYPE d;
  1696.      enum machine_mode mode;
  1697. {
  1698.   jmp_buf output_constant_handler;
  1699.  
  1700.   if (setjmp (output_constant_handler))
  1701.     {
  1702.       error ("floating point trap outputting a constant");
  1703. #ifdef REAL_IS_NOT_DOUBLE
  1704.       bzero ((char *) &d, sizeof d);
  1705.       d = dconst0;
  1706. #else
  1707.       d = 0;
  1708. #endif
  1709.     }
  1710.  
  1711.   set_float_handler (output_constant_handler);
  1712.  
  1713.   switch (mode)
  1714.     {
  1715. #ifdef ASM_OUTPUT_BYTE_FLOAT
  1716.     case QFmode:
  1717.       ASM_OUTPUT_BYTE_FLOAT (asm_out_file, d);
  1718.       break;
  1719. #endif
  1720. #ifdef ASM_OUTPUT_SHORT_FLOAT
  1721.     case HFmode:
  1722.       ASM_OUTPUT_SHORT_FLOAT (asm_out_file, d);
  1723.       break;
  1724. #endif
  1725. #ifdef ASM_OUTPUT_THREE_QUARTER_FLOAT
  1726.     case TQFmode:
  1727.       ASM_OUTPUT_THREE_QUARTER_FLOAT (asm_out_file, d);
  1728.       break;
  1729. #endif
  1730. #ifdef ASM_OUTPUT_FLOAT
  1731.     case SFmode:
  1732.       ASM_OUTPUT_FLOAT (asm_out_file, d);
  1733.       break;
  1734. #endif
  1735.  
  1736. #ifdef ASM_OUTPUT_DOUBLE
  1737.     case DFmode:
  1738.       ASM_OUTPUT_DOUBLE (asm_out_file, d);
  1739.       break;
  1740. #endif
  1741.  
  1742. #ifdef ASM_OUTPUT_LONG_DOUBLE
  1743.     case XFmode:
  1744.     case TFmode:
  1745.       ASM_OUTPUT_LONG_DOUBLE (asm_out_file, d);
  1746.       break;
  1747. #endif
  1748.  
  1749.     default:
  1750.       abort ();
  1751.     }
  1752.  
  1753.   set_float_handler (NULL_PTR);
  1754. }
  1755.  
  1756. /* Here we combine duplicate floating constants to make
  1757.    CONST_DOUBLE rtx's, and force those out to memory when necessary.  */
  1758.  
  1759. /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
  1760.    They are chained through the CONST_DOUBLE_CHAIN.
  1761.    A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
  1762.    In that case, CONST_DOUBLE_MEM is either a MEM,
  1763.    or const0_rtx if no MEM has been made for this CONST_DOUBLE yet.
  1764.  
  1765.    (CONST_DOUBLE_MEM is used only for top-level functions.
  1766.    See force_const_mem for explanation.)  */
  1767.  
  1768. static rtx const_double_chain;
  1769.  
  1770. /* Return a CONST_DOUBLE or CONST_INT for a value specified as a pair of ints.
  1771.    For an integer, I0 is the low-order word and I1 is the high-order word.
  1772.    For a real number, I0 is the word with the low address
  1773.    and I1 is the word with the high address.  */
  1774.  
  1775. rtx
  1776. immed_double_const (i0, i1, mode)
  1777.      HOST_WIDE_INT i0, i1;
  1778.      enum machine_mode mode;
  1779. {
  1780.   register rtx r;
  1781.   int in_current_obstack;
  1782.  
  1783.   if (GET_MODE_CLASS (mode) == MODE_INT
  1784.       || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
  1785.     {
  1786.       /* We clear out all bits that don't belong in MODE, unless they and our
  1787.      sign bit are all one.  So we get either a reasonable negative value
  1788.      or a reasonable unsigned value for this mode.  */
  1789.       int width = GET_MODE_BITSIZE (mode);
  1790.       if (width < HOST_BITS_PER_WIDE_INT
  1791.       && ((i0 & ((HOST_WIDE_INT) (-1) << (width - 1)))
  1792.           != ((HOST_WIDE_INT) (-1) << (width - 1))))
  1793.     i0 &= ((HOST_WIDE_INT) 1 << width) - 1, i1 = 0;
  1794.       else if (width == HOST_BITS_PER_WIDE_INT
  1795.            && ! (i1 == ~0 && i0 < 0))
  1796.     i1 = 0;
  1797.       else if (width > 2 * HOST_BITS_PER_WIDE_INT)
  1798.     /* We cannot represent this value as a constant.  */
  1799.     abort ();
  1800.  
  1801.       /* If this would be an entire word for the target, but is not for
  1802.      the host, then sign-extend on the host so that the number will look
  1803.      the same way on the host that it would on the target.
  1804.  
  1805.      For example, when building a 64 bit alpha hosted 32 bit sparc
  1806.      targeted compiler, then we want the 32 bit unsigned value -1 to be
  1807.      represented as a 64 bit value -1, and not as 0x00000000ffffffff.
  1808.      The later confuses the sparc backend.  */
  1809.  
  1810.       if (BITS_PER_WORD < HOST_BITS_PER_WIDE_INT && BITS_PER_WORD == width
  1811.       && (i0 & ((HOST_WIDE_INT) 1 << (width - 1))))
  1812.     i0 |= ((HOST_WIDE_INT) (-1) << width);
  1813.  
  1814.       /* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
  1815.  
  1816.      ??? Strictly speaking, this is wrong if we create a CONST_INT
  1817.      for a large unsigned constant with the size of MODE being
  1818.      HOST_BITS_PER_WIDE_INT and later try to interpret that constant in a
  1819.      wider mode.  In that case we will mis-interpret it as a negative
  1820.      number.
  1821.  
  1822.      Unfortunately, the only alternative is to make a CONST_DOUBLE
  1823.      for any constant in any mode if it is an unsigned constant larger
  1824.      than the maximum signed integer in an int on the host.  However,
  1825.      doing this will break everyone that always expects to see a CONST_INT
  1826.      for SImode and smaller.
  1827.  
  1828.      We have always been making CONST_INTs in this case, so nothing new
  1829.      is being broken.  */
  1830.  
  1831.       if (width <= HOST_BITS_PER_WIDE_INT)
  1832.     i1 = (i0 < 0) ? ~0 : 0;
  1833.  
  1834.       /* If this integer fits in one word, return a CONST_INT.  */
  1835.       if ((i1 == 0 && i0 >= 0)
  1836.       || (i1 == ~0 && i0 < 0))
  1837.     return GEN_INT (i0);
  1838.  
  1839.       /* We use VOIDmode for integers.  */
  1840.       mode = VOIDmode;
  1841.     }
  1842.  
  1843.   /* Search the chain for an existing CONST_DOUBLE with the right value.
  1844.      If one is found, return it.  */
  1845.  
  1846.   for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
  1847.     if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1
  1848.     && GET_MODE (r) == mode)
  1849.       return r;
  1850.  
  1851.   /* No; make a new one and add it to the chain.
  1852.  
  1853.      We may be called by an optimizer which may be discarding any memory
  1854.      allocated during its processing (such as combine and loop).  However,
  1855.      we will be leaving this constant on the chain, so we cannot tolerate
  1856.      freed memory.  So switch to saveable_obstack for this allocation
  1857.      and then switch back if we were in current_obstack.  */
  1858.  
  1859.   push_obstacks_nochange ();
  1860.   rtl_in_saveable_obstack ();
  1861.   r = gen_rtx (CONST_DOUBLE, mode, 0, i0, i1);
  1862.   pop_obstacks ();
  1863.  
  1864.   /* Don't touch const_double_chain in nested function; see force_const_mem.
  1865.      Also, don't touch it if not inside any function.  */
  1866.   if (outer_function_chain == 0 && current_function_decl != 0)
  1867.     {
  1868.       CONST_DOUBLE_CHAIN (r) = const_double_chain;
  1869.       const_double_chain = r;
  1870.     }
  1871.  
  1872.   /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
  1873.      Actual use of mem-slot is only through force_const_mem.  */
  1874.  
  1875.   CONST_DOUBLE_MEM (r) = const0_rtx;
  1876.  
  1877.   return r;
  1878. }
  1879.  
  1880. /* Return a CONST_DOUBLE for a specified `double' value
  1881.    and machine mode.  */
  1882.  
  1883. rtx
  1884. immed_real_const_1 (d, mode)
  1885.      REAL_VALUE_TYPE d;
  1886.      enum machine_mode mode;
  1887. {
  1888.   union real_extract u;
  1889.   register rtx r;
  1890.   int in_current_obstack;
  1891.  
  1892.   /* Get the desired `double' value as a sequence of ints
  1893.      since that is how they are stored in a CONST_DOUBLE.  */
  1894.  
  1895.   u.d = d;
  1896.  
  1897.   /* Detect special cases.  */
  1898.  
  1899.   /* Avoid REAL_VALUES_EQUAL here in order to distinguish minus zero.  */
  1900.   if (!bcmp ((char *) &dconst0, (char *) &d, sizeof d))
  1901.     return CONST0_RTX (mode);
  1902.   /* Check for NaN first, because some ports (specifically the i386) do not
  1903.      emit correct ieee-fp code by default, and thus will generate a core
  1904.      dump here if we pass a NaN to REAL_VALUES_EQUAL and if REAL_VALUES_EQUAL
  1905.      does a floating point comparison.  */
  1906.   else if (! REAL_VALUE_ISNAN (d) && REAL_VALUES_EQUAL (dconst1, d))
  1907.     return CONST1_RTX (mode);
  1908.  
  1909.   if (sizeof u == 2 * sizeof (HOST_WIDE_INT))
  1910.     return immed_double_const (u.i[0], u.i[1], mode);
  1911.  
  1912.   /* The rest of this function handles the case where
  1913.      a float value requires more than 2 ints of space.
  1914.      It will be deleted as dead code on machines that don't need it.  */
  1915.  
  1916.   /* Search the chain for an existing CONST_DOUBLE with the right value.
  1917.      If one is found, return it.  */
  1918.  
  1919.   for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
  1920.     if (! bcmp ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u)
  1921.     && GET_MODE (r) == mode)
  1922.       return r;
  1923.  
  1924.   /* No; make a new one and add it to the chain.
  1925.  
  1926.      We may be called by an optimizer which may be discarding any memory
  1927.      allocated during its processing (such as combine and loop).  However,
  1928.      we will be leaving this constant on the chain, so we cannot tolerate
  1929.      freed memory.  So switch to saveable_obstack for this allocation
  1930.      and then switch back if we were in current_obstack.  */
  1931.  
  1932.   push_obstacks_nochange ();
  1933.   rtl_in_saveable_obstack ();
  1934.   r = rtx_alloc (CONST_DOUBLE);
  1935.   PUT_MODE (r, mode);
  1936.   bcopy ((char *) &u, (char *) &CONST_DOUBLE_LOW (r), sizeof u);
  1937.   pop_obstacks ();
  1938.  
  1939.   /* Don't touch const_double_chain in nested function; see force_const_mem.
  1940.      Also, don't touch it if not inside any function.  */
  1941.   if (outer_function_chain == 0 && current_function_decl != 0)
  1942.     {
  1943.       CONST_DOUBLE_CHAIN (r) = const_double_chain;
  1944.       const_double_chain = r;
  1945.     }
  1946.  
  1947.   /* Store const0_rtx in CONST_DOUBLE_MEM since this CONST_DOUBLE is on the
  1948.      chain, but has not been allocated memory.  Actual use of CONST_DOUBLE_MEM
  1949.      is only through force_const_mem.  */
  1950.  
  1951.   CONST_DOUBLE_MEM (r) = const0_rtx;
  1952.  
  1953.   return r;
  1954. }
  1955.  
  1956. /* Return a CONST_DOUBLE rtx for a value specified by EXP,
  1957.    which must be a REAL_CST tree node.  */
  1958.  
  1959. rtx
  1960. immed_real_const (exp)
  1961.      tree exp;
  1962. {
  1963.   return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)));
  1964. }
  1965.  
  1966. /* At the end of a function, forget the memory-constants
  1967.    previously made for CONST_DOUBLEs.  Mark them as not on real_constant_chain.
  1968.    Also clear out real_constant_chain and clear out all the chain-pointers.  */
  1969.  
  1970. void
  1971. clear_const_double_mem ()
  1972. {
  1973.   register rtx r, next;
  1974.  
  1975.   /* Don't touch CONST_DOUBLE_MEM for nested functions.
  1976.      See force_const_mem for explanation.  */
  1977.   if (outer_function_chain != 0)
  1978.     return;
  1979.  
  1980.   for (r = const_double_chain; r; r = next)
  1981.     {
  1982.       next = CONST_DOUBLE_CHAIN (r);
  1983.       CONST_DOUBLE_CHAIN (r) = 0;
  1984.       CONST_DOUBLE_MEM (r) = cc0_rtx;
  1985.     }
  1986.   const_double_chain = 0;
  1987. }
  1988.  
  1989. /* Given an expression EXP with a constant value,
  1990.    reduce it to the sum of an assembler symbol and an integer.
  1991.    Store them both in the structure *VALUE.
  1992.    Abort if EXP does not reduce.  */
  1993.  
  1994. struct addr_const
  1995. {
  1996.   rtx base;
  1997.   HOST_WIDE_INT offset;
  1998. };
  1999.  
  2000. static void
  2001. decode_addr_const (exp, value)
  2002.      tree exp;
  2003.      struct addr_const *value;
  2004. {
  2005.   register tree target = TREE_OPERAND (exp, 0);
  2006.   register int offset = 0;
  2007.   register rtx x;
  2008.  
  2009.   while (1)
  2010.     {
  2011.       if (TREE_CODE (target) == COMPONENT_REF
  2012.       && (TREE_CODE (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1)))
  2013.           == INTEGER_CST))
  2014.     {
  2015.       offset += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (TREE_OPERAND (target, 1))) / BITS_PER_UNIT;
  2016.       target = TREE_OPERAND (target, 0);
  2017.     }
  2018.       else if (TREE_CODE (target) == ARRAY_REF)
  2019.     {
  2020.       if (TREE_CODE (TREE_OPERAND (target, 1)) != INTEGER_CST
  2021.           || TREE_CODE (TYPE_SIZE (TREE_TYPE (target))) != INTEGER_CST)
  2022.         abort ();
  2023.       offset += ((TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target)))
  2024.               * TREE_INT_CST_LOW (TREE_OPERAND (target, 1)))
  2025.              / BITS_PER_UNIT);
  2026.       target = TREE_OPERAND (target, 0);
  2027.     }
  2028.       else
  2029.     break;
  2030.     }
  2031.  
  2032.   switch (TREE_CODE (target))
  2033.     {
  2034.     case VAR_DECL:
  2035.     case FUNCTION_DECL:
  2036.       x = DECL_RTL (target);
  2037.       break;
  2038.  
  2039.     case LABEL_DECL:
  2040.       if (output_bytecode)
  2041.     /* FIXME: this may not be correct, check it */
  2042.     x = bc_gen_rtx (TREE_STRING_POINTER (target), 0, (struct bc_label *) 0);
  2043.       else
  2044.     x = gen_rtx (MEM, FUNCTION_MODE,
  2045.              gen_rtx (LABEL_REF, VOIDmode,
  2046.                   label_rtx (TREE_OPERAND (exp, 0))));
  2047.       break;
  2048.  
  2049.     case REAL_CST:
  2050.     case STRING_CST:
  2051.     case COMPLEX_CST:
  2052.     case CONSTRUCTOR:
  2053.       x = TREE_CST_RTL (target);
  2054.       break;
  2055.  
  2056.     default:
  2057.       abort ();
  2058.     }
  2059.  
  2060.   if (!output_bytecode)
  2061.     {
  2062.       if (GET_CODE (x) != MEM)
  2063.     abort ();
  2064.       x = XEXP (x, 0);
  2065.     }
  2066.  
  2067.   value->base = x;
  2068.   value->offset = offset;
  2069. }
  2070.  
  2071. /* Uniquize all constants that appear in memory.
  2072.    Each constant in memory thus far output is recorded
  2073.    in `const_hash_table' with a `struct constant_descriptor'
  2074.    that contains a polish representation of the value of
  2075.    the constant.
  2076.  
  2077.    We cannot store the trees in the hash table
  2078.    because the trees may be temporary.  */
  2079.  
  2080. struct constant_descriptor
  2081. {
  2082.   struct constant_descriptor *next;
  2083.   char *label;
  2084.   char contents[1];
  2085. };
  2086.  
  2087. #define HASHBITS 30
  2088. #define MAX_HASH_TABLE 1009
  2089. static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE];
  2090.  
  2091. /* Compute a hash code for a constant expression.  */
  2092.  
  2093. int
  2094. const_hash (exp)
  2095.      tree exp;
  2096. {
  2097.   register char *p;
  2098.   register int len, hi, i;
  2099.   register enum tree_code code = TREE_CODE (exp);
  2100.  
  2101.   if (code == INTEGER_CST)
  2102.     {
  2103.       p = (char *) &TREE_INT_CST_LOW (exp);
  2104.       len = 2 * sizeof TREE_INT_CST_LOW (exp);
  2105.     }
  2106.   else if (code == REAL_CST)
  2107.     {
  2108.       p = (char *) &TREE_REAL_CST (exp);
  2109.       len = sizeof TREE_REAL_CST (exp);
  2110.     }
  2111.   else if (code == STRING_CST)
  2112.     p = TREE_STRING_POINTER (exp), len = TREE_STRING_LENGTH (exp);
  2113.   else if (code == COMPLEX_CST)
  2114.     return const_hash (TREE_REALPART (exp)) * 5
  2115.       + const_hash (TREE_IMAGPART (exp));
  2116.   else if (code == CONSTRUCTOR)
  2117.     {
  2118.       register tree link;
  2119.  
  2120.       /* For record type, include the type in the hashing.
  2121.      We do not do so for array types
  2122.      because (1) the sizes of the elements are sufficient
  2123.      and (2) distinct array types can have the same constructor.
  2124.      Instead, we include the array size because the constructor could
  2125.      be shorter.  */
  2126.       if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
  2127.     hi = ((HOST_WIDE_INT) TREE_TYPE (exp) & ((1 << HASHBITS) - 1))
  2128.       % MAX_HASH_TABLE;
  2129.       else
  2130.     hi = ((5 + int_size_in_bytes (TREE_TYPE (exp)))
  2131.            & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE;
  2132.  
  2133.       for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
  2134.     if (TREE_VALUE (link))
  2135.       hi = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE;
  2136.  
  2137.       return hi;
  2138.     }
  2139.   else if (code == ADDR_EXPR)
  2140.     {
  2141.       struct addr_const value;
  2142.       decode_addr_const (exp, &value);
  2143.       if (GET_CODE (value.base) == SYMBOL_REF)
  2144.     {
  2145.       /* Don't hash the address of the SYMBOL_REF;
  2146.          only use the offset and the symbol name.  */
  2147.       hi = value.offset;
  2148.       p = XSTR (value.base, 0);
  2149.       for (i = 0; p[i] != 0; i++)
  2150.         hi = ((hi * 613) + (unsigned)(p[i]));
  2151.     }
  2152.       else if (GET_CODE (value.base) == LABEL_REF)
  2153.     hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13;
  2154.  
  2155.       hi &= (1 << HASHBITS) - 1;
  2156.       hi %= MAX_HASH_TABLE;
  2157.       return hi;
  2158.     }
  2159.   else if (code == PLUS_EXPR || code == MINUS_EXPR)
  2160.     return const_hash (TREE_OPERAND (exp, 0)) * 9
  2161.       +  const_hash (TREE_OPERAND (exp, 1));
  2162.   else if (code == NOP_EXPR || code == CONVERT_EXPR)
  2163.     return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2;
  2164.  
  2165.   /* Compute hashing function */
  2166.   hi = len;
  2167.   for (i = 0; i < len; i++)
  2168.     hi = ((hi * 613) + (unsigned)(p[i]));
  2169.  
  2170.   hi &= (1 << HASHBITS) - 1;
  2171.   hi %= MAX_HASH_TABLE;
  2172.   return hi;
  2173. }
  2174.  
  2175. /* Compare a constant expression EXP with a constant-descriptor DESC.
  2176.    Return 1 if DESC describes a constant with the same value as EXP.  */
  2177.  
  2178. static int
  2179. compare_constant (exp, desc)
  2180.      tree exp;
  2181.      struct constant_descriptor *desc;
  2182. {
  2183.   return 0 != compare_constant_1 (exp, desc->contents);
  2184. }
  2185.  
  2186. /* Compare constant expression EXP with a substring P of a constant descriptor.
  2187.    If they match, return a pointer to the end of the substring matched.
  2188.    If they do not match, return 0.
  2189.  
  2190.    Since descriptors are written in polish prefix notation,
  2191.    this function can be used recursively to test one operand of EXP
  2192.    against a subdescriptor, and if it succeeds it returns the
  2193.    address of the subdescriptor for the next operand.  */
  2194.  
  2195. static char *
  2196. compare_constant_1 (exp, p)
  2197.      tree exp;
  2198.      char *p;
  2199. {
  2200.   register char *strp;
  2201.   register int len;
  2202.   register enum tree_code code = TREE_CODE (exp);
  2203.  
  2204.   if (code != (enum tree_code) *p++)
  2205.     return 0;
  2206.  
  2207.   if (code == INTEGER_CST)
  2208.     {
  2209.       /* Integer constants are the same only if the same width of type.  */
  2210.       if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
  2211.     return 0;
  2212.       strp = (char *) &TREE_INT_CST_LOW (exp);
  2213.       len = 2 * sizeof TREE_INT_CST_LOW (exp);
  2214.     }
  2215.   else if (code == REAL_CST)
  2216.     {
  2217.       /* Real constants are the same only if the same width of type.  */
  2218.       if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
  2219.     return 0;
  2220.       strp = (char *) &TREE_REAL_CST (exp);
  2221.       len = sizeof TREE_REAL_CST (exp);
  2222.     }
  2223.   else if (code == STRING_CST)
  2224.     {
  2225.       if (flag_writable_strings)
  2226.     return 0;
  2227.       strp = TREE_STRING_POINTER (exp);
  2228.       len = TREE_STRING_LENGTH (exp);
  2229.       if (bcmp ((char *) &TREE_STRING_LENGTH (exp), p,
  2230.         sizeof TREE_STRING_LENGTH (exp)))
  2231.     return 0;
  2232.       p += sizeof TREE_STRING_LENGTH (exp);
  2233.     }
  2234.   else if (code == COMPLEX_CST)
  2235.     {
  2236.       p = compare_constant_1 (TREE_REALPART (exp), p);
  2237.       if (p == 0) return 0;
  2238.       p = compare_constant_1 (TREE_IMAGPART (exp), p);
  2239.       return p;
  2240.     }
  2241.   else if (code == CONSTRUCTOR)
  2242.     {
  2243.       register tree link;
  2244.       int length = list_length (CONSTRUCTOR_ELTS (exp));
  2245.       tree type;
  2246.  
  2247.       if (bcmp ((char *) &length, p, sizeof length))
  2248.     return 0;
  2249.       p += sizeof length;
  2250.  
  2251.       /* For record constructors, insist that the types match.
  2252.      For arrays, just verify both constructors are for arrays.  */
  2253.       if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
  2254.     type = TREE_TYPE (exp);
  2255.       else
  2256.     type = 0;
  2257.       if (bcmp ((char *) &type, p, sizeof type))
  2258.     return 0;
  2259.       p += sizeof type;
  2260.  
  2261.       /* For arrays, insist that the size in bytes match.  */
  2262.       if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
  2263.     {
  2264.       int size = int_size_in_bytes (TREE_TYPE (exp));
  2265.       if (bcmp ((char *) &size, p, sizeof size))
  2266.         return 0;
  2267.       p += sizeof size;
  2268.     }
  2269.  
  2270.       for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
  2271.     {
  2272.       if (TREE_VALUE (link))
  2273.         {
  2274.           if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0)
  2275.         return 0;
  2276.         }
  2277.       else
  2278.         {
  2279.           tree zero = 0;
  2280.  
  2281.           if (bcmp ((char *) &zero, p, sizeof zero))
  2282.         return 0;
  2283.           p += sizeof zero;
  2284.         }
  2285.     }
  2286.  
  2287.       return p;
  2288.     }
  2289.   else if (code == ADDR_EXPR)
  2290.     {
  2291.       struct addr_const value;
  2292.       decode_addr_const (exp, &value);
  2293.       strp = (char *) &value.offset;
  2294.       len = sizeof value.offset;
  2295.       /* Compare the offset.  */
  2296.       while (--len >= 0)
  2297.     if (*p++ != *strp++)
  2298.       return 0;
  2299.       /* Compare symbol name.  */
  2300.       strp = XSTR (value.base, 0);
  2301.       len = strlen (strp) + 1;
  2302.     }
  2303.   else if (code == PLUS_EXPR || code == MINUS_EXPR)
  2304.     {
  2305.       p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
  2306.       if (p == 0) return 0;
  2307.       p = compare_constant_1 (TREE_OPERAND (exp, 1), p);
  2308.       return p;
  2309.     }
  2310.   else if (code == NOP_EXPR || code == CONVERT_EXPR)
  2311.     {
  2312.       p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
  2313.       return p;
  2314.     }
  2315.  
  2316.   /* Compare constant contents.  */
  2317.   while (--len >= 0)
  2318.     if (*p++ != *strp++)
  2319.       return 0;
  2320.  
  2321.   return p;
  2322. }
  2323.  
  2324. /* Construct a constant descriptor for the expression EXP.
  2325.    It is up to the caller to enter the descriptor in the hash table.  */
  2326.  
  2327. static struct constant_descriptor *
  2328. record_constant (exp)
  2329.      tree exp;
  2330. {
  2331.   struct constant_descriptor *next = 0;
  2332.   char *label = 0;
  2333.  
  2334.   /* Make a struct constant_descriptor.  The first two pointers will
  2335.      be filled in later.  Here we just leave space for them.  */
  2336.  
  2337.   obstack_grow (&permanent_obstack, (char *) &next, sizeof next);
  2338.   obstack_grow (&permanent_obstack, (char *) &label, sizeof label);
  2339.   record_constant_1 (exp);
  2340.   return (struct constant_descriptor *) obstack_finish (&permanent_obstack);
  2341. }
  2342.  
  2343. /* Add a description of constant expression EXP
  2344.    to the object growing in `permanent_obstack'.
  2345.    No need to return its address; the caller will get that
  2346.    from the obstack when the object is complete.  */
  2347.  
  2348. static void
  2349. record_constant_1 (exp)
  2350.      tree exp;
  2351. {
  2352.   register char *strp;
  2353.   register int len;
  2354.   register enum tree_code code = TREE_CODE (exp);
  2355.  
  2356.   obstack_1grow (&permanent_obstack, (unsigned int) code);
  2357.  
  2358.   if (code == INTEGER_CST)
  2359.     {
  2360.       obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
  2361.       strp = (char *) &TREE_INT_CST_LOW (exp);
  2362.       len = 2 * sizeof TREE_INT_CST_LOW (exp);
  2363.     }
  2364.   else if (code == REAL_CST)
  2365.     {
  2366.       obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
  2367.       strp = (char *) &TREE_REAL_CST (exp);
  2368.       len = sizeof TREE_REAL_CST (exp);
  2369.     }
  2370.   else if (code == STRING_CST)
  2371.     {
  2372.       if (flag_writable_strings)
  2373.     return;
  2374.       strp = TREE_STRING_POINTER (exp);
  2375.       len = TREE_STRING_LENGTH (exp);
  2376.       obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp),
  2377.             sizeof TREE_STRING_LENGTH (exp));
  2378.     }
  2379.   else if (code == COMPLEX_CST)
  2380.     {
  2381.       record_constant_1 (TREE_REALPART (exp));
  2382.       record_constant_1 (TREE_IMAGPART (exp));
  2383.       return;
  2384.     }
  2385.   else if (code == CONSTRUCTOR)
  2386.     {
  2387.       register tree link;
  2388.       int length = list_length (CONSTRUCTOR_ELTS (exp));
  2389.       tree type;
  2390.  
  2391.       obstack_grow (&permanent_obstack, (char *) &length, sizeof length);
  2392.  
  2393.       /* For record constructors, insist that the types match.
  2394.      For arrays, just verify both constructors are for arrays.  */
  2395.       if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
  2396.     type = TREE_TYPE (exp);
  2397.       else
  2398.     type = 0;
  2399.       obstack_grow (&permanent_obstack, (char *) &type, sizeof type);
  2400.  
  2401.       /* For arrays, insist that the size in bytes match.  */
  2402.       if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
  2403.     {
  2404.       int size = int_size_in_bytes (TREE_TYPE (exp));
  2405.       obstack_grow (&permanent_obstack, (char *) &size, sizeof size);
  2406.     }
  2407.  
  2408.       for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
  2409.     {
  2410.       if (TREE_VALUE (link))
  2411.         record_constant_1 (TREE_VALUE (link));
  2412.       else
  2413.         {
  2414.           tree zero = 0;
  2415.  
  2416.           obstack_grow (&permanent_obstack, (char *) &zero, sizeof zero);
  2417.         }
  2418.     }
  2419.  
  2420.       return;
  2421.     }
  2422.   else if (code == ADDR_EXPR)
  2423.     {
  2424.       struct addr_const value;
  2425.       decode_addr_const (exp, &value);
  2426.       /* Record the offset.  */
  2427.       obstack_grow (&permanent_obstack,
  2428.             (char *) &value.offset, sizeof value.offset);
  2429.       /* Record the symbol name.  */
  2430.       obstack_grow (&permanent_obstack, XSTR (value.base, 0),
  2431.             strlen (XSTR (value.base, 0)) + 1);
  2432.       return;
  2433.     }
  2434.   else if (code == PLUS_EXPR || code == MINUS_EXPR)
  2435.     {
  2436.       record_constant_1 (TREE_OPERAND (exp, 0));
  2437.       record_constant_1 (TREE_OPERAND (exp, 1));
  2438.       return;
  2439.     }
  2440.   else if (code == NOP_EXPR || code == CONVERT_EXPR)
  2441.     {
  2442.       record_constant_1 (TREE_OPERAND (exp, 0));
  2443.       return;
  2444.     }
  2445.  
  2446.   /* Record constant contents.  */
  2447.   obstack_grow (&permanent_obstack, strp, len);
  2448. }
  2449.  
  2450. /* Record a list of constant expressions that were passed to
  2451.    output_constant_def but that could not be output right away.  */
  2452.  
  2453. struct deferred_constant
  2454. {
  2455.   struct deferred_constant *next;
  2456.   tree exp;
  2457.   int reloc;
  2458.   int labelno;
  2459. };
  2460.  
  2461. static struct deferred_constant *deferred_constants;
  2462.  
  2463. /* Nonzero means defer output of addressed subconstants
  2464.    (i.e., those for which output_constant_def is called.)  */
  2465. static int defer_addressed_constants_flag;
  2466.  
  2467. /* Start deferring output of subconstants.  */
  2468.  
  2469. void
  2470. defer_addressed_constants ()
  2471. {
  2472.   defer_addressed_constants_flag++;
  2473. }
  2474.  
  2475. /* Stop deferring output of subconstants,
  2476.    and output now all those that have been deferred.  */
  2477.  
  2478. void
  2479. output_deferred_addressed_constants ()
  2480. {
  2481.   struct deferred_constant *p, *next;
  2482.  
  2483.   defer_addressed_constants_flag--;
  2484.  
  2485.   if (defer_addressed_constants_flag > 0)
  2486.     return;
  2487.  
  2488.   for (p = deferred_constants; p; p = next)
  2489.     {
  2490.       output_constant_def_contents (p->exp, p->reloc, p->labelno);
  2491.       next = p->next;
  2492.       free (p);
  2493.     }
  2494.  
  2495.   deferred_constants = 0;
  2496. }
  2497.  
  2498. /* Make a copy of the whole tree structure for a constant.
  2499.    This handles the same types of nodes that compare_constant
  2500.    and record_constant handle.  */
  2501.  
  2502. static tree
  2503. copy_constant (exp)
  2504.      tree exp;
  2505. {
  2506.   switch (TREE_CODE (exp))
  2507.     {
  2508.     case INTEGER_CST:
  2509.     case REAL_CST:
  2510.     case STRING_CST:
  2511.     case ADDR_EXPR:
  2512.       /* For ADDR_EXPR, we do not want to copy the decl
  2513.      whose address is requested.  */
  2514.       return copy_node (exp);
  2515.  
  2516.     case COMPLEX_CST:
  2517.       return build_complex (copy_constant (TREE_REALPART (exp)),
  2518.                 copy_constant (TREE_IMAGPART (exp)));
  2519.  
  2520.     case PLUS_EXPR:
  2521.     case MINUS_EXPR:
  2522.       return build (TREE_CODE (exp), TREE_TYPE (exp),
  2523.             copy_constant (TREE_OPERAND (exp, 0)),
  2524.             copy_constant (TREE_OPERAND (exp, 1)));
  2525.  
  2526.     case NOP_EXPR:
  2527.     case CONVERT_EXPR:
  2528.       return build1 (TREE_CODE (exp), TREE_TYPE (exp),
  2529.              copy_constant (TREE_OPERAND (exp, 0)));
  2530.  
  2531.     case CONSTRUCTOR:
  2532.       {
  2533.     tree copy = copy_node (exp);
  2534.     tree list = copy_list (CONSTRUCTOR_ELTS (exp));
  2535.     tree tail;
  2536.  
  2537.     CONSTRUCTOR_ELTS (copy) = list;
  2538.     for (tail = list; tail; tail = TREE_CHAIN (tail))
  2539.       TREE_VALUE (tail) = copy_constant (TREE_VALUE (tail));
  2540.  
  2541.     return copy;
  2542.       }
  2543.  
  2544.     default:
  2545.       abort ();
  2546.     }
  2547. }
  2548.  
  2549. /* Return an rtx representing a reference to constant data in memory
  2550.    for the constant expression EXP.
  2551.  
  2552.    If assembler code for such a constant has already been output,
  2553.    return an rtx to refer to it.
  2554.    Otherwise, output such a constant in memory (or defer it for later)
  2555.    and generate an rtx for it.
  2556.  
  2557.    The TREE_CST_RTL of EXP is set up to point to that rtx.
  2558.    The const_hash_table records which constants already have label strings.  */
  2559.  
  2560. rtx
  2561. output_constant_def (exp)
  2562.      tree exp;
  2563. {
  2564.   register int hash;
  2565.   register struct constant_descriptor *desc;
  2566.   char label[256];
  2567.   char *found = 0;
  2568.   int reloc;
  2569.   register rtx def;
  2570.  
  2571.   if (TREE_CODE (exp) == INTEGER_CST)
  2572.     abort ();            /* No TREE_CST_RTL slot in these.  */
  2573.  
  2574.   if (TREE_CST_RTL (exp))
  2575.     return TREE_CST_RTL (exp);
  2576.  
  2577.   /* Make sure any other constants whose addresses appear in EXP
  2578.      are assigned label numbers.  */
  2579.  
  2580.   reloc = output_addressed_constants (exp);
  2581.  
  2582.   /* Compute hash code of EXP.  Search the descriptors for that hash code
  2583.      to see if any of them describes EXP.  If yes, the descriptor records
  2584.      the label number already assigned.  */
  2585.  
  2586.   hash = const_hash (exp) % MAX_HASH_TABLE;
  2587.       
  2588.   for (desc = const_hash_table[hash]; desc; desc = desc->next)
  2589.     if (compare_constant (exp, desc))
  2590.       {
  2591.     found = desc->label;
  2592.     break;
  2593.       }
  2594.       
  2595.   if (found == 0)
  2596.     {
  2597.       /* No constant equal to EXP is known to have been output.
  2598.      Make a constant descriptor to enter EXP in the hash table.
  2599.      Assign the label number and record it in the descriptor for
  2600.      future calls to this function to find.  */
  2601.       
  2602.       /* Create a string containing the label name, in LABEL.  */
  2603.       ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
  2604.  
  2605.       desc = record_constant (exp);
  2606.       desc->next = const_hash_table[hash];
  2607.       desc->label
  2608.     = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
  2609.       const_hash_table[hash] = desc;
  2610.     }
  2611.   else
  2612.     {
  2613.       /* Create a string containing the label name, in LABEL.  */
  2614.       ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
  2615.     }
  2616.   
  2617.   /* We have a symbol name; construct the SYMBOL_REF and the MEM.  */
  2618.  
  2619.   push_obstacks_nochange ();
  2620.   if (TREE_PERMANENT (exp))
  2621.     end_temporary_allocation ();
  2622.  
  2623.   def = gen_rtx (SYMBOL_REF, Pmode, desc->label);
  2624.       
  2625.   TREE_CST_RTL (exp)
  2626.     = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), def);
  2627.   RTX_UNCHANGING_P (TREE_CST_RTL (exp)) = 1;
  2628.   if (AGGREGATE_TYPE_P (TREE_TYPE (exp)))
  2629.     MEM_IN_STRUCT_P (TREE_CST_RTL (exp)) = 1;
  2630.  
  2631.   pop_obstacks ();
  2632.  
  2633.   /* Optionally set flags or add text to the name to record information
  2634.      such as that it is a function name.  If the name is changed, the macro
  2635.      ASM_OUTPUT_LABELREF will have to know how to strip this information.  */
  2636. #ifdef ENCODE_SECTION_INFO
  2637.   ENCODE_SECTION_INFO (exp);
  2638. #endif
  2639.  
  2640.   /* If this is the first time we've seen this particular constant,
  2641.      output it (or defer its output for later).  */
  2642.   if (found == 0)
  2643.     {
  2644.       if (defer_addressed_constants_flag)
  2645.     {
  2646.       struct deferred_constant *p;
  2647.       p = (struct deferred_constant *) xmalloc (sizeof (struct deferred_constant));
  2648.  
  2649.       push_obstacks_nochange ();
  2650.       suspend_momentary ();
  2651.       p->exp = copy_constant (exp);
  2652.       pop_obstacks ();
  2653.       p->reloc = reloc;
  2654.       p->labelno = const_labelno++;
  2655.       p->next = deferred_constants;
  2656.       deferred_constants = p;
  2657.     }
  2658.       else
  2659.     output_constant_def_contents (exp, reloc, const_labelno++);
  2660.     }
  2661.  
  2662.   return TREE_CST_RTL (exp);
  2663. }
  2664.  
  2665. /* Now output assembler code to define the label for EXP,
  2666.    and follow it with the data of EXP.  */
  2667.  
  2668. static void
  2669. output_constant_def_contents (exp, reloc, labelno)
  2670.      tree exp;
  2671.      int reloc;
  2672.      int labelno;
  2673. {
  2674.   int align;
  2675.  
  2676.   if (IN_NAMED_SECTION (exp))
  2677.     named_section (TREE_STRING_POINTER (DECL_SECTION_NAME (exp)));
  2678.   else
  2679.     {
  2680.       /* First switch to text section, except for writable strings.  */
  2681. #ifdef SELECT_SECTION
  2682.       SELECT_SECTION (exp, reloc);
  2683. #else
  2684.       if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
  2685.       || (flag_pic && reloc))
  2686.     data_section ();
  2687.       else
  2688.     readonly_data_section ();
  2689. #endif
  2690.     }
  2691.  
  2692.   /* Align the location counter as required by EXP's data type.  */
  2693.   align = TYPE_ALIGN (TREE_TYPE (exp));
  2694. #ifdef CONSTANT_ALIGNMENT
  2695.   align = CONSTANT_ALIGNMENT (exp, align);
  2696. #endif
  2697.  
  2698.   if (align > BITS_PER_UNIT)
  2699.     {
  2700.       if (!output_bytecode)
  2701.     {
  2702.       ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
  2703.     }
  2704.       else
  2705.     {
  2706.       BC_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
  2707.     }
  2708.     }
  2709.  
  2710.   /* Output the label itself.  */
  2711.   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", labelno);
  2712.  
  2713.   /* Output the value of EXP.  */
  2714.   output_constant (exp,
  2715.            (TREE_CODE (exp) == STRING_CST
  2716.             ? TREE_STRING_LENGTH (exp)
  2717.             : int_size_in_bytes (TREE_TYPE (exp))));
  2718.  
  2719. }
  2720.  
  2721. /* Similar hash facility for making memory-constants
  2722.    from constant rtl-expressions.  It is used on RISC machines
  2723.    where immediate integer arguments and constant addresses are restricted
  2724.    so that such constants must be stored in memory.
  2725.  
  2726.    This pool of constants is reinitialized for each function
  2727.    so each function gets its own constants-pool that comes right before it.
  2728.  
  2729.    All structures allocated here are discarded when functions are saved for
  2730.    inlining, so they do not need to be allocated permanently.  */
  2731.  
  2732. #define MAX_RTX_HASH_TABLE 61
  2733. static struct constant_descriptor **const_rtx_hash_table;
  2734.  
  2735. /* Structure to represent sufficient information about a constant so that
  2736.    it can be output when the constant pool is output, so that function
  2737.    integration can be done, and to simplify handling on machines that reference
  2738.    constant pool as base+displacement.  */
  2739.  
  2740. struct pool_constant
  2741. {
  2742.   struct constant_descriptor *desc;
  2743.   struct pool_constant *next;
  2744.   enum machine_mode mode;
  2745.   rtx constant;
  2746.   int labelno;
  2747.   int align;
  2748.   int offset;
  2749. };
  2750.  
  2751. /* Pointers to first and last constant in pool.  */
  2752.  
  2753. static struct pool_constant *first_pool, *last_pool;
  2754.  
  2755. /* Current offset in constant pool (does not include any machine-specific
  2756.    header.  */
  2757.  
  2758. static int pool_offset;
  2759.  
  2760. /* Structure used to maintain hash table mapping symbols used to their
  2761.    corresponding constants.  */
  2762.  
  2763. struct pool_sym
  2764. {
  2765.   char *label;
  2766.   struct pool_constant *pool;
  2767.   struct pool_sym *next;
  2768. };
  2769.  
  2770. static struct pool_sym **const_rtx_sym_hash_table;
  2771.  
  2772. /* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true.
  2773.    The argument is XSTR (... , 0)  */
  2774.  
  2775. #define SYMHASH(LABEL)    \
  2776.   ((((HOST_WIDE_INT) (LABEL)) & ((1 << HASHBITS) - 1))  % MAX_RTX_HASH_TABLE)
  2777.  
  2778. /* Initialize constant pool hashing for next function.  */
  2779.  
  2780. void
  2781. init_const_rtx_hash_table ()
  2782. {
  2783.   const_rtx_hash_table
  2784.     = ((struct constant_descriptor **)
  2785.        oballoc (MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *)));
  2786.   const_rtx_sym_hash_table
  2787.     = ((struct pool_sym **)
  2788.        oballoc (MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *)));
  2789.   bzero ((char *) const_rtx_hash_table,
  2790.      MAX_RTX_HASH_TABLE * sizeof (struct constant_descriptor *));
  2791.   bzero ((char *) const_rtx_sym_hash_table,
  2792.      MAX_RTX_HASH_TABLE * sizeof (struct pool_sym *));
  2793.  
  2794.   first_pool = last_pool = 0;
  2795.   pool_offset = 0;
  2796. }
  2797.  
  2798. /* Save and restore it for a nested function.  */
  2799.  
  2800. void
  2801. save_varasm_status (p)
  2802.      struct function *p;
  2803. {
  2804.   p->const_rtx_hash_table = const_rtx_hash_table;
  2805.   p->const_rtx_sym_hash_table = const_rtx_sym_hash_table;
  2806.   p->first_pool = first_pool;
  2807.   p->last_pool = last_pool;
  2808.   p->pool_offset = pool_offset;
  2809. }
  2810.  
  2811. void
  2812. restore_varasm_status (p)
  2813.      struct function *p;
  2814. {
  2815.   const_rtx_hash_table = p->const_rtx_hash_table;
  2816.   const_rtx_sym_hash_table = p->const_rtx_sym_hash_table;
  2817.   first_pool = p->first_pool;
  2818.   last_pool = p->last_pool;
  2819.   pool_offset = p->pool_offset;
  2820. }
  2821.  
  2822. enum kind { RTX_DOUBLE, RTX_INT };
  2823.  
  2824. struct rtx_const
  2825. {
  2826. #ifdef ONLY_INT_FIELDS
  2827.   unsigned int kind : 16;
  2828.   unsigned int mode : 16;
  2829. #else
  2830.   enum kind kind : 16;
  2831.   enum machine_mode mode : 16;
  2832. #endif
  2833.   union {
  2834.     union real_extract du;
  2835.     struct addr_const addr;
  2836.   } un;
  2837. };
  2838.  
  2839. /* Express an rtx for a constant integer (perhaps symbolic)
  2840.    as the sum of a symbol or label plus an explicit integer.
  2841.    They are stored into VALUE.  */
  2842.  
  2843. static void
  2844. decode_rtx_const (mode, x, value)
  2845.      enum machine_mode mode;
  2846.      rtx x;
  2847.      struct rtx_const *value;
  2848. {
  2849.   /* Clear the whole structure, including any gaps.  */
  2850.  
  2851.   {
  2852.     int *p = (int *) value;
  2853.     int *end = (int *) (value + 1);
  2854.     while (p < end)
  2855.       *p++ = 0;
  2856.   }
  2857.  
  2858.   value->kind = RTX_INT;    /* Most usual kind. */
  2859.   value->mode = mode;
  2860.  
  2861.   switch (GET_CODE (x))
  2862.     {
  2863.     case CONST_DOUBLE:
  2864.       value->kind = RTX_DOUBLE;
  2865.       if (GET_MODE (x) != VOIDmode)
  2866.     value->mode = GET_MODE (x);
  2867.       bcopy ((char *) &CONST_DOUBLE_LOW (x),
  2868.          (char *) &value->un.du, sizeof value->un.du);
  2869.       break;
  2870.  
  2871.     case CONST_INT:
  2872.       value->un.addr.offset = INTVAL (x);
  2873.       break;
  2874.  
  2875.     case SYMBOL_REF:
  2876.     case LABEL_REF:
  2877.     case PC:
  2878.       value->un.addr.base = x;
  2879.       break;
  2880.  
  2881.     case CONST:
  2882.       x = XEXP (x, 0);
  2883.       if (GET_CODE (x) == PLUS)
  2884.     {
  2885.       value->un.addr.base = XEXP (x, 0);
  2886.       if (GET_CODE (XEXP (x, 1)) != CONST_INT)
  2887.         abort ();
  2888.       value->un.addr.offset = INTVAL (XEXP (x, 1));
  2889.     }
  2890.       else if (GET_CODE (x) == MINUS)
  2891.     {
  2892.       value->un.addr.base = XEXP (x, 0);
  2893.       if (GET_CODE (XEXP (x, 1)) != CONST_INT)
  2894.         abort ();
  2895.       value->un.addr.offset = - INTVAL (XEXP (x, 1));
  2896.     }
  2897.       else
  2898.     abort ();
  2899.       break;
  2900.  
  2901.     default:
  2902.       abort ();
  2903.     }
  2904.  
  2905.   if (value->kind == RTX_INT && value->un.addr.base != 0)
  2906.     switch (GET_CODE (value->un.addr.base))
  2907.       {
  2908.       case SYMBOL_REF:
  2909.       case LABEL_REF:
  2910.     /* Use the string's address, not the SYMBOL_REF's address,
  2911.        for the sake of addresses of library routines.
  2912.        For a LABEL_REF, compare labels.  */
  2913.     value->un.addr.base = XEXP (value->un.addr.base, 0);
  2914.       }
  2915. }
  2916.  
  2917. /* Given a MINUS expression, simplify it if both sides
  2918.    include the same symbol.  */
  2919.  
  2920. rtx
  2921. simplify_subtraction (x)
  2922.      rtx x;
  2923. {
  2924.   struct rtx_const val0, val1;
  2925.  
  2926.   decode_rtx_const (GET_MODE (x), XEXP (x, 0), &val0);
  2927.   decode_rtx_const (GET_MODE (x), XEXP (x, 1), &val1);
  2928.  
  2929.   if (val0.un.addr.base == val1.un.addr.base)
  2930.     return GEN_INT (val0.un.addr.offset - val1.un.addr.offset);
  2931.   return x;
  2932. }
  2933.  
  2934. /* Compute a hash code for a constant RTL expression.  */
  2935.  
  2936. int
  2937. const_hash_rtx (mode, x)
  2938.      enum machine_mode mode;
  2939.      rtx x;
  2940. {
  2941.   register int hi, i;
  2942.  
  2943.   struct rtx_const value;
  2944.   decode_rtx_const (mode, x, &value);
  2945.  
  2946.   /* Compute hashing function */
  2947.   hi = 0;
  2948.   for (i = 0; i < sizeof value / sizeof (int); i++)
  2949.     hi += ((int *) &value)[i];
  2950.  
  2951.   hi &= (1 << HASHBITS) - 1;
  2952.   hi %= MAX_RTX_HASH_TABLE;
  2953.   return hi;
  2954. }
  2955.  
  2956. /* Compare a constant rtl object X with a constant-descriptor DESC.
  2957.    Return 1 if DESC describes a constant with the same value as X.  */
  2958.  
  2959. static int
  2960. compare_constant_rtx (mode, x, desc)
  2961.      enum machine_mode mode;
  2962.      rtx x;
  2963.      struct constant_descriptor *desc;
  2964. {
  2965.   register int *p = (int *) desc->contents;
  2966.   register int *strp;
  2967.   register int len;
  2968.   struct rtx_const value;
  2969.  
  2970.   decode_rtx_const (mode, x, &value);
  2971.   strp = (int *) &value;
  2972.   len = sizeof value / sizeof (int);
  2973.  
  2974.   /* Compare constant contents.  */
  2975.   while (--len >= 0)
  2976.     if (*p++ != *strp++)
  2977.       return 0;
  2978.  
  2979.   return 1;
  2980. }
  2981.  
  2982. /* Construct a constant descriptor for the rtl-expression X.
  2983.    It is up to the caller to enter the descriptor in the hash table.  */
  2984.  
  2985. static struct constant_descriptor *
  2986. record_constant_rtx (mode, x)
  2987.      enum machine_mode mode;
  2988.      rtx x;
  2989. {
  2990.   struct constant_descriptor *ptr;
  2991.   char *label;
  2992.   struct rtx_const value;
  2993.  
  2994.   decode_rtx_const (mode, x, &value);
  2995.  
  2996.   /* Put these things in the saveable obstack so we can ensure it won't
  2997.      be freed if we are called from combine or some other phase that discards
  2998.      memory allocated from function_obstack (current_obstack).  */
  2999.   obstack_grow (saveable_obstack, &ptr, sizeof ptr);
  3000.   obstack_grow (saveable_obstack, &label, sizeof label);
  3001.  
  3002.   /* Record constant contents.  */
  3003.   obstack_grow (saveable_obstack, &value, sizeof value);
  3004.  
  3005.   return (struct constant_descriptor *) obstack_finish (saveable_obstack);
  3006. }
  3007.  
  3008. /* Given a constant rtx X, make (or find) a memory constant for its value
  3009.    and return a MEM rtx to refer to it in memory.  */
  3010.  
  3011. rtx
  3012. force_const_mem (mode, x)
  3013.      enum machine_mode mode;
  3014.      rtx x;
  3015. {
  3016.   register int hash;
  3017.   register struct constant_descriptor *desc;
  3018.   char label[256];
  3019.   char *found = 0;
  3020.   rtx def;
  3021.  
  3022.   /* If we want this CONST_DOUBLE in the same mode as it is in memory
  3023.      (this will always be true for floating CONST_DOUBLEs that have been
  3024.      placed in memory, but not for VOIDmode (integer) CONST_DOUBLEs),
  3025.      use the previous copy.  Otherwise, make a new one.  Note that in
  3026.      the unlikely event that this same CONST_DOUBLE is used in two different
  3027.      modes in an alternating fashion, we will allocate a lot of different
  3028.      memory locations, but this should be extremely rare.  */
  3029.  
  3030.   /* Don't use CONST_DOUBLE_MEM in a nested function.
  3031.      Nested functions have their own constant pools,
  3032.      so they can't share the same values in CONST_DOUBLE_MEM
  3033.      with the containing function.  */
  3034.   if (outer_function_chain == 0)
  3035.     if (GET_CODE (x) == CONST_DOUBLE
  3036.     && GET_CODE (CONST_DOUBLE_MEM (x)) == MEM
  3037.     && GET_MODE (CONST_DOUBLE_MEM (x)) == mode)
  3038.       return CONST_DOUBLE_MEM (x);
  3039.  
  3040.   /* Compute hash code of X.  Search the descriptors for that hash code
  3041.      to see if any of them describes X.  If yes, the descriptor records
  3042.      the label number already assigned.  */
  3043.  
  3044.   hash = const_hash_rtx (mode, x);
  3045.  
  3046.   for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next)
  3047.     if (compare_constant_rtx (mode, x, desc))
  3048.       {
  3049.     found = desc->label;
  3050.     break;
  3051.       }
  3052.  
  3053.   if (found == 0)
  3054.     {
  3055.       register struct pool_constant *pool;
  3056.       register struct pool_sym *sym;
  3057.       int align;
  3058.  
  3059.       /* No constant equal to X is known to have been output.
  3060.      Make a constant descriptor to enter X in the hash table.
  3061.      Assign the label number and record it in the descriptor for
  3062.      future calls to this function to find.  */
  3063.  
  3064.       desc = record_constant_rtx (mode, x);
  3065.       desc->next = const_rtx_hash_table[hash];
  3066.       const_rtx_hash_table[hash] = desc;
  3067.  
  3068.       /* Align the location counter as required by EXP's data type.  */
  3069.       align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode);
  3070.       if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  3071.     align = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
  3072.  
  3073.       pool_offset += align - 1;
  3074.       pool_offset &= ~ (align - 1);
  3075.  
  3076.       /* If RTL is not being placed into the saveable obstack, make a
  3077.      copy of X that is in the saveable obstack in case we are being
  3078.      called from combine or some other phase that discards memory
  3079.      it allocates.  We need only do this if it is a CONST, since
  3080.      no other RTX should be allocated in this situation. */
  3081.       if (rtl_obstack != saveable_obstack
  3082.       && GET_CODE (x) == CONST)
  3083.     {
  3084.       push_obstacks_nochange ();
  3085.       rtl_in_saveable_obstack ();
  3086.  
  3087.       x = gen_rtx (CONST, GET_MODE (x), 
  3088.                gen_rtx (PLUS, GET_MODE (x), 
  3089.                 XEXP (XEXP (x, 0), 0), XEXP (XEXP (x, 0), 1)));
  3090.       pop_obstacks ();
  3091.     }
  3092.  
  3093.       /* Allocate a pool constant descriptor, fill it in, and chain it in.  */
  3094.  
  3095.       pool = (struct pool_constant *) savealloc (sizeof (struct pool_constant));
  3096.       pool->desc = desc;
  3097.       pool->constant = x;
  3098.       pool->mode = mode;
  3099.       pool->labelno = const_labelno;
  3100.       pool->align = align;
  3101.       pool->offset = pool_offset;
  3102.       pool->next = 0;
  3103.  
  3104.       if (last_pool == 0)
  3105.     first_pool = pool;
  3106.       else
  3107.     last_pool->next = pool;
  3108.  
  3109.       last_pool = pool;
  3110.       pool_offset += GET_MODE_SIZE (mode);
  3111.  
  3112.       /* Create a string containing the label name, in LABEL.  */
  3113.       ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
  3114.  
  3115.       ++const_labelno;
  3116.  
  3117.       desc->label = found
  3118.     = (char *) obstack_copy0 (saveable_obstack, label, strlen (label));
  3119.  
  3120.       /* Add label to symbol hash table.  */
  3121.       hash = SYMHASH (found);
  3122.       sym = (struct pool_sym *) savealloc (sizeof (struct pool_sym));
  3123.       sym->label = found;
  3124.       sym->pool = pool;
  3125.       sym->next = const_rtx_sym_hash_table[hash];
  3126.       const_rtx_sym_hash_table[hash] = sym;
  3127.     }
  3128.  
  3129.   /* We have a symbol name; construct the SYMBOL_REF and the MEM.  */
  3130.  
  3131.   def = gen_rtx (MEM, mode, gen_rtx (SYMBOL_REF, Pmode, found));
  3132.  
  3133.   RTX_UNCHANGING_P (def) = 1;
  3134.   /* Mark the symbol_ref as belonging to this constants pool.  */
  3135.   CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1;
  3136.   current_function_uses_const_pool = 1;
  3137.  
  3138.   if (outer_function_chain == 0)
  3139.     if (GET_CODE (x) == CONST_DOUBLE)
  3140.       {
  3141.     if (CONST_DOUBLE_MEM (x) == cc0_rtx)
  3142.       {
  3143.         CONST_DOUBLE_CHAIN (x) = const_double_chain;
  3144.         const_double_chain = x;
  3145.       }
  3146.     CONST_DOUBLE_MEM (x) = def;
  3147.       }
  3148.  
  3149.   return def;
  3150. }
  3151.  
  3152. /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to
  3153.    the corresponding pool_constant structure.  */
  3154.  
  3155. static struct pool_constant *
  3156. find_pool_constant (addr)
  3157.      rtx addr;
  3158. {
  3159.   struct pool_sym *sym;
  3160.   char *label = XSTR (addr, 0);
  3161.  
  3162.   for (sym = const_rtx_sym_hash_table[SYMHASH (label)]; sym; sym = sym->next)
  3163.     if (sym->label == label)
  3164.       return sym->pool;
  3165.  
  3166.   abort ();
  3167. }
  3168.  
  3169. /* Given a constant pool SYMBOL_REF, return the corresponding constant.  */
  3170.  
  3171. rtx
  3172. get_pool_constant (addr)
  3173.      rtx addr;
  3174. {
  3175.   return (find_pool_constant (addr))->constant;
  3176. }
  3177.  
  3178. /* Similar, return the mode.  */
  3179.  
  3180. enum machine_mode
  3181. get_pool_mode (addr)
  3182.      rtx addr;
  3183. {
  3184.   return (find_pool_constant (addr))->mode;
  3185. }
  3186.  
  3187. /* Similar, return the offset in the constant pool.  */
  3188.  
  3189. int
  3190. get_pool_offset (addr)
  3191.      rtx addr;
  3192. {
  3193.   return (find_pool_constant (addr))->offset;
  3194. }
  3195.  
  3196. /* Return the size of the constant pool.  */
  3197.  
  3198. int
  3199. get_pool_size ()
  3200. {
  3201.   return pool_offset;
  3202. }
  3203.  
  3204. /* Write all the constants in the constant pool.  */
  3205.  
  3206. void
  3207. output_constant_pool (fnname, fndecl)
  3208.      char *fnname;
  3209.      tree fndecl;
  3210. {
  3211.   struct pool_constant *pool;
  3212.   rtx x;
  3213.   union real_extract u;
  3214.  
  3215. #ifdef ASM_OUTPUT_POOL_PROLOGUE
  3216.   ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool_offset);
  3217. #endif
  3218.  
  3219.   for (pool = first_pool; pool; pool = pool->next)
  3220.     {
  3221.       x = pool->constant;
  3222.  
  3223.       /* See if X is a LABEL_REF (or a CONST referring to a LABEL_REF)
  3224.      whose CODE_LABEL has been deleted.  This can occur if a jump table
  3225.      is eliminated by optimization.  If so, write a constant of zero
  3226.      instead.  Note that this can also happen by turning the
  3227.      CODE_LABEL into a NOTE.  */
  3228.       if (((GET_CODE (x) == LABEL_REF
  3229.         && (INSN_DELETED_P (XEXP (x, 0))
  3230.         || GET_CODE (XEXP (x, 0)) == NOTE)))
  3231.       || (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS
  3232.           && GET_CODE (XEXP (XEXP (x, 0), 0)) == LABEL_REF
  3233.           && (INSN_DELETED_P (XEXP (XEXP (XEXP (x, 0), 0), 0))
  3234.           || GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == NOTE)))
  3235.     x = const0_rtx;
  3236.  
  3237.       /* First switch to correct section.  */
  3238. #ifdef SELECT_RTX_SECTION
  3239.       SELECT_RTX_SECTION (pool->mode, x);
  3240. #else
  3241.       readonly_data_section ();
  3242. #endif
  3243.  
  3244. #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
  3245.       ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, pool->mode,
  3246.                      pool->align, pool->labelno, done);
  3247. #endif
  3248.  
  3249.       if (pool->align > 1)
  3250.     ASM_OUTPUT_ALIGN (asm_out_file, exact_log2 (pool->align));
  3251.  
  3252.       /* Output the label.  */
  3253.       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", pool->labelno);
  3254.  
  3255.       /* Output the value of the constant itself.  */
  3256.       switch (GET_MODE_CLASS (pool->mode))
  3257.     {
  3258.     case MODE_FLOAT:
  3259.       if (GET_CODE (x) != CONST_DOUBLE)
  3260.         abort ();
  3261.  
  3262.       bcopy ((char *) &CONST_DOUBLE_LOW (x), (char *) &u, sizeof u);
  3263.       assemble_real (u.d, pool->mode);
  3264.       break;
  3265.  
  3266.     case MODE_INT:
  3267.     case MODE_PARTIAL_INT:
  3268.       assemble_integer (x, GET_MODE_SIZE (pool->mode), 1);
  3269.       break;
  3270.  
  3271.     default:
  3272.       abort ();
  3273.     }
  3274.  
  3275.     done: ;
  3276.     }
  3277.  
  3278.   /* Done with this pool.  */
  3279.   first_pool = last_pool = 0;
  3280. }
  3281.  
  3282. /* Find all the constants whose addresses are referenced inside of EXP,
  3283.    and make sure assembler code with a label has been output for each one.
  3284.    Indicate whether an ADDR_EXPR has been encountered.  */
  3285.  
  3286. int
  3287. output_addressed_constants (exp)
  3288.      tree exp;
  3289. {
  3290.   int reloc = 0;
  3291.  
  3292.   switch (TREE_CODE (exp))
  3293.     {
  3294.     case ADDR_EXPR:
  3295.       {
  3296.     register tree constant = TREE_OPERAND (exp, 0);
  3297.  
  3298.     while (TREE_CODE (constant) == COMPONENT_REF)
  3299.       {
  3300.         constant = TREE_OPERAND (constant, 0);
  3301.       }
  3302.  
  3303.     if (TREE_CODE_CLASS (TREE_CODE (constant)) == 'c'
  3304.         || TREE_CODE (constant) == CONSTRUCTOR)
  3305.       /* No need to do anything here
  3306.          for addresses of variables or functions.  */
  3307.       output_constant_def (constant);
  3308.       }
  3309.       reloc = 1;
  3310.       break;
  3311.  
  3312.     case PLUS_EXPR:
  3313.     case MINUS_EXPR:
  3314.       reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
  3315.       reloc |= output_addressed_constants (TREE_OPERAND (exp, 1));
  3316.       break;
  3317.  
  3318.     case NOP_EXPR:
  3319.     case CONVERT_EXPR:
  3320.     case NON_LVALUE_EXPR:
  3321.       reloc = output_addressed_constants (TREE_OPERAND (exp, 0));
  3322.       break;
  3323.  
  3324.     case CONSTRUCTOR:
  3325.       {
  3326.     register tree link;
  3327.     for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
  3328.       if (TREE_VALUE (link) != 0)
  3329.         reloc |= output_addressed_constants (TREE_VALUE (link));
  3330.       }
  3331.       break;
  3332.  
  3333.     case ERROR_MARK:
  3334.       break;
  3335.     }
  3336.   return reloc;
  3337. }
  3338.  
  3339.  
  3340. /* Output assembler for byte constant */
  3341. void
  3342. output_byte_asm (byte)
  3343.   int byte;
  3344. {
  3345.   if (output_bytecode)
  3346.     bc_emit_const ((char *) &byte, sizeof (char));
  3347. #ifdef ASM_OUTPUT_BYTE
  3348.   else
  3349.     {
  3350.       ASM_OUTPUT_BYTE (asm_out_file, byte);
  3351.     }
  3352. #endif
  3353. }
  3354.  
  3355. /* Output assembler code for constant EXP to FILE, with no label.
  3356.    This includes the pseudo-op such as ".int" or ".byte", and a newline.
  3357.    Assumes output_addressed_constants has been done on EXP already.
  3358.  
  3359.    Generate exactly SIZE bytes of assembler data, padding at the end
  3360.    with zeros if necessary.  SIZE must always be specified.
  3361.  
  3362.    SIZE is important for structure constructors,
  3363.    since trailing members may have been omitted from the constructor.
  3364.    It is also important for initialization of arrays from string constants
  3365.    since the full length of the string constant might not be wanted.
  3366.    It is also needed for initialization of unions, where the initializer's
  3367.    type is just one member, and that may not be as long as the union.
  3368.  
  3369.    There a case in which we would fail to output exactly SIZE bytes:
  3370.    for a structure constructor that wants to produce more than SIZE bytes.
  3371.    But such constructors will never be generated for any possible input.  */
  3372.  
  3373. void
  3374. output_constant (exp, size)
  3375.      register tree exp;
  3376.      register int size;
  3377. {
  3378.   register enum tree_code code = TREE_CODE (TREE_TYPE (exp));
  3379.   rtx x;
  3380.  
  3381.   if (size == 0)
  3382.     return;
  3383.  
  3384.   /* Eliminate the NON_LVALUE_EXPR_EXPR that makes a cast not be an lvalue.
  3385.      That way we get the constant (we hope) inside it.  Also, strip
  3386.      off any NOP_EXPR that converts between two record or union types.  */
  3387.   while ((TREE_CODE (exp) == NOP_EXPR 
  3388.       && (TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0))
  3389.           || TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
  3390.           || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE
  3391.           || TREE_CODE (TREE_TYPE (exp)) == QUAL_UNION_TYPE))
  3392.      || TREE_CODE (exp) == NON_LVALUE_EXPR)
  3393.     exp = TREE_OPERAND (exp, 0);
  3394.  
  3395.   /* Allow a constructor with no elements for any data type.
  3396.      This means to fill the space with zeros.  */
  3397.   if (TREE_CODE (exp) == CONSTRUCTOR && CONSTRUCTOR_ELTS (exp) == 0)
  3398.     {
  3399.       if (output_bytecode)
  3400.     bc_emit_const_skip (size);
  3401.       else
  3402.     assemble_zeros (size);
  3403.       return;
  3404.     }
  3405.  
  3406.   switch (code)
  3407.     {
  3408.     case CHAR_TYPE:
  3409.     case BOOLEAN_TYPE:
  3410.     case INTEGER_TYPE:
  3411.     case ENUMERAL_TYPE:
  3412.     case POINTER_TYPE:
  3413.     case REFERENCE_TYPE:
  3414.       /* ??? What about       (int)((float)(int)&foo + 4)    */
  3415.       while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
  3416.          || TREE_CODE (exp) == NON_LVALUE_EXPR)
  3417.     exp = TREE_OPERAND (exp, 0);
  3418.  
  3419.       if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
  3420.                        EXPAND_INITIALIZER),
  3421.                   size, 0))
  3422.     error ("initializer for integer value is too complicated");
  3423.       size = 0;
  3424.       break;
  3425.  
  3426.     case REAL_TYPE:
  3427.       if (TREE_CODE (exp) != REAL_CST)
  3428.     error ("initializer for floating value is not a floating constant");
  3429.  
  3430.       assemble_real (TREE_REAL_CST (exp),
  3431.              mode_for_size (size * BITS_PER_UNIT, MODE_FLOAT, 0));
  3432.       size = 0;
  3433.       break;
  3434.  
  3435.     case COMPLEX_TYPE:
  3436.       output_constant (TREE_REALPART (exp), size / 2);
  3437.       output_constant (TREE_IMAGPART (exp), size / 2);
  3438.       size -= (size / 2) * 2;
  3439.       break;
  3440.  
  3441.     case ARRAY_TYPE:
  3442.       if (TREE_CODE (exp) == CONSTRUCTOR)
  3443.     {
  3444.       output_constructor (exp, size);
  3445.       return;
  3446.     }
  3447.       else if (TREE_CODE (exp) == STRING_CST)
  3448.     {
  3449.       int excess = 0;
  3450.  
  3451.       if (size > TREE_STRING_LENGTH (exp))
  3452.         {
  3453.           excess = size - TREE_STRING_LENGTH (exp);
  3454.           size = TREE_STRING_LENGTH (exp);
  3455.         }
  3456.  
  3457.       assemble_string (TREE_STRING_POINTER (exp), size);
  3458.       size = excess;
  3459.     }
  3460.       else
  3461.     abort ();
  3462.       break;
  3463.  
  3464.     case RECORD_TYPE:
  3465.     case UNION_TYPE:
  3466.       if (TREE_CODE (exp) == CONSTRUCTOR)
  3467.     output_constructor (exp, size);
  3468.       else
  3469.     abort ();
  3470.       return;
  3471.     }
  3472.  
  3473.   if (size > 0)
  3474.     assemble_zeros (size);
  3475. }
  3476.  
  3477.  
  3478. /* Bytecode specific code to output assembler for integer. */
  3479. static void
  3480. bc_assemble_integer (exp, size)
  3481.     tree exp;
  3482.     int size;
  3483. {
  3484.   tree const_part;
  3485.   tree addr_part;
  3486.   tree tmp;
  3487.  
  3488.   /* FIXME: is this fold() business going to be as good as the
  3489.      expand_expr() using EXPAND_SUM above in the RTL case?  I
  3490.      hate RMS.
  3491.      FIXME: Copied as is from BC-GCC1; may need work. Don't hate. -bson */
  3492.   
  3493.   exp = fold (exp);
  3494.   
  3495.   while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR)
  3496.     exp = TREE_OPERAND (exp, 0);
  3497.   if (TREE_CODE (exp) == INTEGER_CST)
  3498.     {
  3499.       const_part = exp;
  3500.       addr_part = 0;
  3501.     }
  3502.   else if (TREE_CODE (exp) == PLUS_EXPR)
  3503.     {
  3504.       const_part = TREE_OPERAND (exp, 0);
  3505.       while (TREE_CODE (const_part) == NOP_EXPR
  3506.          || TREE_CODE (const_part) == CONVERT_EXPR)
  3507.     const_part = TREE_OPERAND (const_part, 0);
  3508.       addr_part = TREE_OPERAND (exp, 1);
  3509.       while (TREE_CODE (addr_part) == NOP_EXPR
  3510.          || TREE_CODE (addr_part) == CONVERT_EXPR)
  3511.     addr_part = TREE_OPERAND (addr_part, 0);
  3512.       if (TREE_CODE (const_part) != INTEGER_CST)
  3513.     tmp = const_part, const_part = addr_part, addr_part = tmp;
  3514.       if (TREE_CODE (const_part) != INTEGER_CST
  3515.       || TREE_CODE (addr_part) != ADDR_EXPR)
  3516.     abort ();        /* FIXME: we really haven't considered
  3517.                    all the possible cases here.  */
  3518.     }
  3519.   else if (TREE_CODE (exp) == ADDR_EXPR)
  3520.     {
  3521.       const_part = integer_zero_node;
  3522.       addr_part = exp;
  3523.     }
  3524.   else
  3525.     abort ();        /* FIXME: ditto previous.  */
  3526.   
  3527.   if (addr_part == 0)
  3528.     {
  3529.       if (size == 1)
  3530.     {
  3531.       char c = TREE_INT_CST_LOW (const_part);
  3532.       bc_emit (&c, 1);
  3533.       size -= 1;
  3534.     }
  3535.       else if (size == 2)
  3536.     {
  3537.       short s = TREE_INT_CST_LOW (const_part);
  3538.       bc_emit ((char *) &s, 2);
  3539.       size -= 2;
  3540.     }
  3541.       else if (size == 4)
  3542.     {
  3543.       int i = TREE_INT_CST_LOW (const_part);
  3544.       bc_emit ((char *) &i, 4);
  3545.       size -= 4;
  3546.     }
  3547.       else if (size == 8)
  3548.     {
  3549. #if WORDS_BIG_ENDIAN
  3550.       int i = TREE_INT_CST_HIGH (const_part);
  3551.       bc_emit ((char *) &i, 4);
  3552.       i = TREE_INT_CST_LOW (const_part);
  3553.       bc_emit ((char *) &i, 4);
  3554. #else
  3555.       int i = TREE_INT_CST_LOW (const_part);
  3556.       bc_emit ((char *) &i, 4);
  3557.       i = TREE_INT_CST_HIGH (const_part);
  3558.       bc_emit ((char *) &i, 4);
  3559. #endif
  3560.       size -= 8;
  3561.     }
  3562.     }
  3563.   else
  3564.     if (size == 4
  3565.     && TREE_CODE (TREE_OPERAND (addr_part, 0)) == VAR_DECL)
  3566.       bc_emit_labelref (DECL_ASSEMBLER_NAME (TREE_OPERAND (addr_part, 0)),
  3567.             TREE_INT_CST_LOW (const_part));
  3568.     else
  3569.       abort ();        /* FIXME: there may be more cases.  */
  3570. }
  3571.  
  3572. /* Subroutine of output_constant, used for CONSTRUCTORs
  3573.    (aggregate constants).
  3574.    Generate at least SIZE bytes, padding if necessary.  */
  3575.  
  3576. void
  3577. output_constructor (exp, size)
  3578.      tree exp;
  3579.      int size;
  3580. {
  3581.   register tree link, field = 0;
  3582.   HOST_WIDE_INT min_index = 0;
  3583.   /* Number of bytes output or skipped so far.
  3584.      In other words, current position within the constructor.  */
  3585.   int total_bytes = 0;
  3586.   /* Non-zero means BYTE contains part of a byte, to be output.  */
  3587.   int byte_buffer_in_use = 0;
  3588.   register int byte;
  3589.  
  3590.   if (HOST_BITS_PER_WIDE_INT < BITS_PER_UNIT)
  3591.     abort ();
  3592.  
  3593.   if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
  3594.     field = TYPE_FIELDS (TREE_TYPE (exp));
  3595.  
  3596.   if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
  3597.       && TYPE_DOMAIN (TREE_TYPE (exp)) != 0)
  3598.     min_index
  3599.       = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp))));
  3600.  
  3601.   /* As LINK goes through the elements of the constant,
  3602.      FIELD goes through the structure fields, if the constant is a structure.
  3603.      if the constant is a union, then we override this,
  3604.      by getting the field from the TREE_LIST element.
  3605.      But the constant could also be an array.  Then FIELD is zero.  */
  3606.   for (link = CONSTRUCTOR_ELTS (exp);
  3607.        link;
  3608.        link = TREE_CHAIN (link),
  3609.        field = field ? TREE_CHAIN (field) : 0)
  3610.     {
  3611.       tree val = TREE_VALUE (link);
  3612.       tree index = 0;
  3613.  
  3614.       /* the element in a union constructor specifies the proper field.  */
  3615.  
  3616.       if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
  3617.       || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE)
  3618.     {
  3619.       /* if available, use the type given by link */
  3620.       if (TREE_PURPOSE (link) != 0)
  3621.         field = TREE_PURPOSE (link);
  3622.     }
  3623.  
  3624.       if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
  3625.     index = TREE_PURPOSE (link);
  3626.  
  3627.       /* Eliminate the marker that makes a cast not be an lvalue.  */
  3628.       if (val != 0)
  3629.     STRIP_NOPS (val);
  3630.  
  3631.       if (field == 0 || !DECL_BIT_FIELD (field))
  3632.     {
  3633.       /* An element that is not a bit-field.  */
  3634.  
  3635.       register int fieldsize;
  3636.       /* Since this structure is static,
  3637.          we know the positions are constant.  */
  3638.       int bitpos = (field ? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))
  3639.                  / BITS_PER_UNIT)
  3640.             : 0);
  3641.       if (index != 0)
  3642.         bitpos = (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val)))
  3643.               / BITS_PER_UNIT
  3644.               * (TREE_INT_CST_LOW (index) - min_index));
  3645.  
  3646.       /* Output any buffered-up bit-fields preceding this element.  */
  3647.       if (byte_buffer_in_use)
  3648.         {
  3649.           ASM_OUTPUT_BYTE (asm_out_file, byte);
  3650.           total_bytes++;
  3651.           byte_buffer_in_use = 0;
  3652.         }
  3653.  
  3654.       /* Advance to offset of this element.
  3655.          Note no alignment needed in an array, since that is guaranteed
  3656.          if each element has the proper size.  */
  3657.       if ((field != 0 || index != 0) && bitpos != total_bytes)
  3658.         {
  3659.           if (!output_bytecode)
  3660.         assemble_zeros (bitpos - total_bytes);
  3661.           else
  3662.         bc_emit_const_skip (bitpos - total_bytes);
  3663.           total_bytes = bitpos;
  3664.         }
  3665.  
  3666.       /* Determine size this element should occupy.  */
  3667.       if (field)
  3668.         {
  3669.           if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST)
  3670.         abort ();
  3671.           if (TREE_INT_CST_LOW (DECL_SIZE (field)) > 100000)
  3672.         {
  3673.           /* This avoids overflow trouble.  */
  3674.           tree size_tree = size_binop (CEIL_DIV_EXPR,
  3675.                            DECL_SIZE (field),
  3676.                            size_int (BITS_PER_UNIT));
  3677.           fieldsize = TREE_INT_CST_LOW (size_tree);
  3678.         }
  3679.           else
  3680.         {
  3681.           fieldsize = TREE_INT_CST_LOW (DECL_SIZE (field));
  3682.           fieldsize = (fieldsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
  3683.         }
  3684.         }
  3685.       else
  3686.         fieldsize = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp)));
  3687.  
  3688.       /* Output the element's initial value.  */
  3689.       if (val == 0)
  3690.         assemble_zeros (fieldsize);
  3691.       else
  3692.         output_constant (val, fieldsize);
  3693.  
  3694.       /* Count its size.  */
  3695.       total_bytes += fieldsize;
  3696.     }
  3697.       else if (val != 0 && TREE_CODE (val) != INTEGER_CST)
  3698.     error ("invalid initial value for member `%s'",
  3699.            IDENTIFIER_POINTER (DECL_NAME (field)));
  3700.       else
  3701.     {
  3702.       /* Element that is a bit-field.  */
  3703.  
  3704.       int next_offset = TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
  3705.       int end_offset
  3706.         = (next_offset + TREE_INT_CST_LOW (DECL_SIZE (field)));
  3707.  
  3708.       if (val == 0)
  3709.         val = integer_zero_node;
  3710.  
  3711.       /* If this field does not start in this (or, next) byte,
  3712.          skip some bytes.  */
  3713.       if (next_offset / BITS_PER_UNIT != total_bytes)
  3714.         {
  3715.           /* Output remnant of any bit field in previous bytes.  */
  3716.           if (byte_buffer_in_use)
  3717.         {
  3718.           ASM_OUTPUT_BYTE (asm_out_file, byte);
  3719.           total_bytes++;
  3720.           byte_buffer_in_use = 0;
  3721.         }
  3722.  
  3723.           /* If still not at proper byte, advance to there.  */
  3724.           if (next_offset / BITS_PER_UNIT != total_bytes)
  3725.         {
  3726.           assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes);
  3727.           total_bytes = next_offset / BITS_PER_UNIT;
  3728.         }
  3729.         }
  3730.  
  3731.       if (! byte_buffer_in_use)
  3732.         byte = 0;
  3733.  
  3734.       /* We must split the element into pieces that fall within
  3735.          separate bytes, and combine each byte with previous or
  3736.          following bit-fields.  */
  3737.  
  3738.       /* next_offset is the offset n fbits from the beginning of
  3739.          the structure to the next bit of this element to be processed.
  3740.          end_offset is the offset of the first bit past the end of
  3741.          this element.  */
  3742.       while (next_offset < end_offset)
  3743.         {
  3744.           int this_time;
  3745.           int shift, value;
  3746.           int next_byte = next_offset / BITS_PER_UNIT;
  3747.           int next_bit = next_offset % BITS_PER_UNIT;
  3748.  
  3749.           /* Advance from byte to byte
  3750.          within this element when necessary.  */
  3751.           while (next_byte != total_bytes)
  3752.         {
  3753.           ASM_OUTPUT_BYTE (asm_out_file, byte);
  3754.           total_bytes++;
  3755.           byte = 0;
  3756.         }
  3757.  
  3758.           /* Number of bits we can process at once
  3759.          (all part of the same byte).  */
  3760.           this_time = MIN (end_offset - next_offset,
  3761.                    BITS_PER_UNIT - next_bit);
  3762. #if BYTES_BIG_ENDIAN
  3763.           /* On big-endian machine, take the most significant bits
  3764.          first (of the bits that are significant)
  3765.          and put them into bytes from the most significant end.  */
  3766.           shift = end_offset - next_offset - this_time;
  3767.           /* Don't try to take a bunch of bits that cross
  3768.          the word boundary in the INTEGER_CST.  */
  3769.           if (shift < HOST_BITS_PER_WIDE_INT
  3770.           && shift + this_time > HOST_BITS_PER_WIDE_INT)
  3771.         {
  3772.           this_time -= (HOST_BITS_PER_WIDE_INT - shift);
  3773.           shift = HOST_BITS_PER_WIDE_INT;
  3774.         }
  3775.  
  3776.           /* Now get the bits from the appropriate constant word.  */
  3777.           if (shift < HOST_BITS_PER_WIDE_INT)
  3778.         {
  3779.           value = TREE_INT_CST_LOW (val);
  3780.         }
  3781.           else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
  3782.         {
  3783.           value = TREE_INT_CST_HIGH (val);
  3784.           shift -= HOST_BITS_PER_WIDE_INT;
  3785.         }
  3786.           else
  3787.         abort ();
  3788.           byte |= (((value >> shift)
  3789.             & (((HOST_WIDE_INT) 1 << this_time) - 1))
  3790.                << (BITS_PER_UNIT - this_time - next_bit));
  3791. #else
  3792.           /* On little-endian machines,
  3793.          take first the least significant bits of the value
  3794.          and pack them starting at the least significant
  3795.          bits of the bytes.  */
  3796.           shift = (next_offset
  3797.                - TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)));
  3798.           /* Don't try to take a bunch of bits that cross
  3799.          the word boundary in the INTEGER_CST.  */
  3800.           if (shift < HOST_BITS_PER_WIDE_INT
  3801.           && shift + this_time > HOST_BITS_PER_WIDE_INT)
  3802.         {
  3803.           this_time -= (HOST_BITS_PER_WIDE_INT - shift);
  3804.           shift = HOST_BITS_PER_WIDE_INT;
  3805.         }
  3806.  
  3807.           /* Now get the bits from the appropriate constant word.  */
  3808.           if (shift < HOST_BITS_PER_INT)
  3809.         value = TREE_INT_CST_LOW (val);
  3810.           else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
  3811.         {
  3812.           value = TREE_INT_CST_HIGH (val);
  3813.           shift -= HOST_BITS_PER_WIDE_INT;
  3814.         }
  3815.           else
  3816.         abort ();
  3817.           byte |= ((value >> shift)
  3818.                & (((HOST_WIDE_INT) 1 << this_time) - 1)) << next_bit;
  3819. #endif
  3820.           next_offset += this_time;
  3821.           byte_buffer_in_use = 1;
  3822.         }
  3823.     }
  3824.     }
  3825.   if (byte_buffer_in_use)
  3826.     {
  3827.       ASM_OUTPUT_BYTE (asm_out_file, byte);
  3828.       total_bytes++;
  3829.     }
  3830.   if (total_bytes < size)
  3831.     assemble_zeros (size - total_bytes);
  3832. }
  3833.  
  3834.  
  3835. #ifdef HANDLE_SYSV_PRAGMA
  3836.  
  3837. /* Support #pragma weak by default if WEAK_ASM_OP and ASM_OUTPUT_DEF
  3838.    are defined.  */
  3839. #if defined (WEAK_ASM_OP) && defined (ASM_OUTPUT_DEF)
  3840.  
  3841. /* See c-pragma.c for an identical definition.  */
  3842. enum pragma_state
  3843. {
  3844.   ps_start,
  3845.   ps_done,
  3846.   ps_bad,
  3847.   ps_weak,
  3848.   ps_name,
  3849.   ps_equals,
  3850.   ps_value,
  3851.   ps_pack,
  3852.   ps_left,
  3853.   ps_align,
  3854.   ps_right
  3855. };
  3856.  
  3857. /* Output asm to handle ``#pragma weak'' */
  3858. void
  3859. handle_pragma_weak (what, asm_out_file, name, value)
  3860.      enum pragma_state what;
  3861.      FILE *asm_out_file;
  3862.      char *name, *value;
  3863. {
  3864.   if (what == ps_name || what == ps_value)
  3865.     {
  3866.       fprintf (asm_out_file, "\t%s\t", WEAK_ASM_OP);
  3867.  
  3868.       if (output_bytecode)
  3869.     BC_OUTPUT_LABELREF (asm_out_file, name);
  3870.       else
  3871.     ASM_OUTPUT_LABELREF (asm_out_file, name);
  3872.  
  3873.       fputc ('\n', asm_out_file);
  3874.       if (what == ps_value)
  3875.     ASM_OUTPUT_DEF (asm_out_file, name, value);
  3876.     }
  3877.   else if (! (what == ps_done || what == ps_start))
  3878.     warning ("malformed `#pragma weak'");
  3879. }
  3880.  
  3881. #endif /* HANDLE_PRAGMA_WEAK or (WEAK_ASM_OP and SET_ASM_OP) */
  3882.  
  3883. #endif /* WEAK_ASM_OP && ASM_OUTPUT_DEF */
  3884.